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.
精彩评论