Skip to content
Advertisement

Convert Jquery code to javascript for .bind event in jquery [closed]

I want to convert .bind of jQuery to JavaScript. Here is the code:

JavaScript

Can anybody please help?

Advertisement

Answer

Related to the Mozilla documentation of javascript :

Add an event listener on any element should be coded as :

JavaScript

Remove an event listener on any element should be coded as :

JavaScript

Example :

JavaScript

But a question persist : Why would you not use jQuery to bind your events ?

By the way, .bind() is deprecated and should be replaced by .on() in the latest releases.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement