开发者

Jquery Ajax loading Problem

开发者 https://www.devze.com 2022-12-23 17:35 出处:网络
I have a function to load a html part into a element in main index page kinda like this $(\".ajax\").click(function() {

I have a function to load a html part into a element in main index page kinda like this

$(".ajax").click(function() {
         //load a page into a element
});

This works But the HTML part which i have just loaded also have links that need to trigger same function above, but it does not.

Until I save that function in a separate .js file and load in the main index file as well as all other files from where I need to trigger that function even though these internal files are going to loaded into the the first main file .

Is there any way for a function in 开发者_JS百科the index file to run from the html document that is loaded inside a element.


Your question is not completely clear, but if you want elements with the ajax class inside the loaded content to trigger the event, you can use live(), like this:

$(".ajax").live("click", function() {
         //load a page into a element
});
0

精彩评论

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