开发者

Link Loaded from other file via jquery is not working

I opened a link which looks exactly like this: http://localhost/anysite/#data_aa

Then, jquery performs the following:

$('a[href^="data_"]').click(function(){
    //code to be executed and at end,
    $("anyDIV").load('anyfile.php?parameter=anyvalue');
});

This selects all the links where the href attribute starts with "data_" to load data from PHP file.

Data and links are loaded successfully but the loaded links do not work whi开发者_开发百科ch exactly looks as same I mentioned in beginning like this http://localhost/anysite/#data_ss...

Hope, You understood my problem and will be able to help me......


You need to use the live method.

$('a[href^="data_"]').live('click',function() {
    //code to be executed and at end,
    $("anyDIV").load('anyfile.php?parameter=anyvalue');
});

The click bind happens at page load, so any content dynamically added afterwards wont be included in that bind, the live method facilitates this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜