I have a div with Class.
For example
<div class="button check"></div>.The css is defined for both ‘button’,’check’. I want to access the above div through jquery and write something in the div.I tried with
$('.button check').html("sample data");
I do not see anything being written when I run the page.
Please help me.
Just chain the CSS classes together, separated by periods:
You will also see better performance in some browsers, by specifying the tag name as well:
Update: After reading Brian’s answer, I re-read the original question I realized you might be under the impression you need to use both to reference the
div. If you had:Then chaining selectors (i.e.
.button.cancel) would make sense. However, if it was the onlydivon the page or you wanted all thedivswithbuttonclass, you don’t need both classes:This would select it fine: