I want to pass few parameters to click() event in jQuery, I tried following but it's not working:
commentbtn.click(function(id, name){
alert(id);
});
And also if we use bind then how we'll do that:
commentbtn.bind('click', function(id, name){
alert(id);
});
idandname. Where do you get them from? Are the values at the time of the click or something initialised at the time you're binding? How will click know what to pass into the function? It will always pass the event object and nothing else.clickdoesn't know what you want want to pass into the handler.