I’ve got the following script, but addClass is not called on the li “spect” when div “tab2” is empty.
Can anybody help me out?
<script type="text/javascript">
$(function(){
if($("div#tab2").html() != "")
{
$("li#spect").addClass("leftmax");
}
});
</script>
<div class="content_container">
<ul class="tabs">
<li><a href="#tab1">TAB1</a></li>
<li id="spect"><a href="#tab2">TAB2</a></li>
<li><a href="#tab3">TAB3</a></li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content"><h2>title<h2></div>
<div id="tab2" class="tab_content"></div>
<div id="tab3" class="tab_content"><h2>title<h2></div>
</div>
</div>
Sounds like you only want to add the class when div#tab2 is empty. If so, then you had a logic error in your comparison operator. Do this instead: