Jquery dynamically assign same function with different parameters to
-
26-10-2019 - |
سؤال
Guys is it possible to assign Double click event to A HREF which is dynamically generated , to which i need to assign a user function with parameter that will differ for each a HREF.kindly let me know.
المحلول
you can use class instead of id and do what Matt said.
$('.Class').live('click',function(event)
{
myFunc($(this));
});
نصائح أخرى
$('.generated').live('click',function(event)
{
//determine params here
myFunc(params);
});
For every 'a' tag that ends up on your page, when it is clicked, it will call myFunc with the jQuery version of itself as the paramater
Try this function. This is a simple JavaScript. Using this method we can assign a function dynamically on an html element.
var funcRef = new Function("testFunction()"); document.getElementById("elementid").onclick=funcRef;
لا تنتمي إلى StackOverflow