Yashwardhan Pauranik Yashwardhan Pauranik - 4 months ago 9
HTML Question

I want to append the mentioned tag in all the div's which does not have class 'block'

I want to append the mentioned tag in all the div's which does not have class 'block'

if( !($('td').hasClass('block')) ){
$('.block').mouseover(function() {
$(this).append('<small style="color:green">Available</small>');
});
$('.block').mouseout(function() {
$('small').remove();
});
}

Answer

modified your code like this

$('td').on('mouseenter', function(){
 if(!($(this).hasClass('block'))){
	$(this).append('<small style="color:green">Available</small>');
	$('td').mouseout(function() {
		$('small').remove();
	});
   	}
});
td { width:150px; height:100px; float:left;background:#666; }
<table>
<tr>
	<td></td><td></td><td class="block"></td>
</tr>
</table>

Comments