If i load a html document in to a div tag for example, is there any way to call a function that i know exists in the loaded html?
Something like this:
$('#foo').load('bar.html', function(){
//call a function in bar.html
});
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You put your JS code in separate file (you load it in your loaded html file) and use
getScriptlike this:So create a separate JS file (good practice not to mix with html or html document) and call it inside your bar.html file:
With this, you can also get that file to work with load using
getScript.