Can I make some functions on a loaded page from Ajax?
I.E.
$(function() {
$.ajax({
url: "loaded.php",
success: function(data) {
$("#content").html(data);
}
});
$("a#edit").click(function(e) {
e.preventDefault();
var newVal = $(this).closest("tr").find("#collapse").html();
$(this).html(newVal);
});
});
Both a#edit and #collapse are elements of the loaded.php and this code is in the index.php page… Will this code work?
You have two options attaching the handler in the success function after you add the html to
#contentor use delegation.Option 1
option 2
http://api.jquery.com/on/