0

I have the below code where I successfully disable the properties

.prop("onclick", null)
.prop("onmouseover", null)
.prop("onmouseout", null);

Now if I want to rebind the click event what should I do.

user2375298
  • 1,001
  • 4
  • 15
  • 28

2 Answers2

0

For adding events back to a element use the bind function.

$("YourElement").bind("event",function(){
    //Do what you want.
    }
Mernayi
  • 237
  • 3
  • 12
0

You can do it with many ways. I don't use to call the prop() method, but I think you just have to use it and set as your second parameter the name of your function.

function yourFunction()
{
   // The job with onclick
}

DOMElement.prop("onclick", "yourFunction");

You can also use anonymous functions.

Use this documentation to work : http://api.jquery.com/prop/

I suggest you should use removeProp() instead of prop("yourprop", null) !

Kern
  • 858
  • 1
  • 8
  • 24