Jquery dynamically assign same function with different parameters to

991 views Asked by At

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.

3

There are 3 answers

1
Thiago On BEST ANSWER

you can use class instead of id and do what Matt said.

$('.Class').live('click',function(event)
{
  myFunc($(this));
});
1
Matt On
$('.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

0
Binu V Pillai On

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;