How would I create a div that when clicked sends an ajax call to a jsp page to replace the content of the div that has been clicked while adding a css class to the changed div?
2 Answers
<div id="foo"></div>
and then:
$('#foo').live('click', function() {
$(this).load('/bar.jsp', function() {
$('#foo').addClass('foobar');
});
});
4 Comments
Livingston Samuel
I'd suggest not to use self closing tags, as
IE 7 & 6 do not support those; so please use the closing tag </div>Darin Dimitrov
@Muki, the .live method allows you to attach an event handler to a DOM element which would persist even if you replace the contents of this element.
Livingston Samuel
@Muki I'd suggest that you go with this method, as the
live method solves the purpose that you are looking for.