$('element').length == 0
Example:
if($('div#mydiv').length == 0)
{
$('body').append('
<div id="mydiv">hello world!</div>
');
}
else
{
$('div#mydiv').html('hello universe!');
}
$('element').length == 0
if($('div#mydiv').length == 0)
{
$('body').append('
<div id="mydiv">hello world!</div>
');
}
else
{
$('div#mydiv').html('hello universe!');
}
<div> <span class=”old_class”>hello there!</span> </div>
$('div span').removeClass('old_class').addClass('new_class');<div> <span class="new_class">hello there!</span> </div>