Try
$(function() { // when DOM is ready
$("#showhidecomment").click(function(){ // when #showhidecomment is clicked
$("#chkcomments").load("sample.jsp"); // load the sample.jsp page in the #chkcomments element
});
});
And change your html (the link part) to
<div>
<div id='showhidecomment'>Show Comments</div>
<div id='chkcomments'></div>
</div>
Since div
elements are invalid inside a
elements.
update for comment
I would add a custom data-url
attribute to those elements (to specify the page to load)
<input id="passed" type="radio" value="P" data-url="some-page.jsp" />
<input id="law" type="radio" value="L" data-url="some-other-page.jsp" />
<input id="ac" type="radio" value="C" data-url="some-third-page.jsp" />
and then apply a single handler to them
$('#verification').on('change','input[type="radio"][data-url]', function(){
if (this.checked){
var url = $(this).data('url');
$("#chkcomments").load( url );
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…