开发者

I unable to access DOM

开发者 https://www.devze.com 2023-01-14 22:17 出处:网络
I\'m using jQuer开发者_运维百科y $.ajax to load my table row data like <table id=\'row-data\'>

I'm using jQuer开发者_运维百科y $.ajax to load my table row data like

<table id='row-data'>
    <tr><td>1001</td></tr>
    <tr><td>1322</td></tr>
    <tr><td>1551</td></tr>
    <tr><td>2341</td></tr>
</table>

In above code I load all <tr> with $.ajax but after load data when I fire any event on <tr> then it's not working, so how to possible to access these row? Please provide me solution for this problem.


Use jQuery.live,refer to here:http://api.jquery.com/live/

It will bind events to dynamically loaded dom.

Best,


you can assign events live, but if you then remove the html with "empty", you must first remove the events assigned to live.

you can also use an update of the events this way:

var yourfunction = function(ev){

  // ...

};

$.fn.updateEvent = function(fn) {
    $(this).bind('click', fn);
};

$("#container").empty().load(...).updateEvent(yourfunction);

jquery.empty
jquery.live
jquery.die

0

精彩评论

暂无评论...
验证码 换一张
取 消