How would I create a div that when clicked sends an ajax call to a jsp page to replace the content of the div th开发者_StackOverflow中文版at has been clicked while adding a css class to the changed div?
<div id="foo"></div>
and then:
$('#foo').live('click', function() {
$(this).load('/bar.jsp', function() {
$('#foo').addClass('foobar');
});
});
the div in the view:
<div id="a" class="a" onclick="clickFunc()">...</div>
the javascript function:
function clickFunc() {$("#a").load("whatever.jsp"); $("#a").addClass("newClass");}
Hope this is what your looking for.
精彩评论