In my page there is an <a>
tag and inside that there is a <div>
. that is shown below:
<a id="test" title="Change Color C开发者_StackOverflowode" href="#" class="modalDlg">
<div class="<%:(colorCode) %>">
</div>
</a>
How can i change the class of <div>
when i click on another button in that page ( i only have the id of the hyperlink (ie , test ) ).
Can i change the class of that <div>
using the hyperlink id (which contains that div) using jquery ?
Very simple way to do this.
$(function() {
$('#button').click(function() {
$('#test div').addClass('foo');
});
});
Try this:
$("<YOUR_BUTTON_SELECTOR>").click(function(){
$("#test div").addClass("<YOUR_CLASS_NAME>");
// OR $("#test div").removeClass("<YOUR_CLASS_NAME>");
});
精彩评论