Spanky
Spanky

Reputation: 709

hasClass and condition not working

For some reason, this isn't launching

<script type="text/javascript">
$(function(){
if ($(h3).hasClass("6") ){
alert ('Todays Date Friday')  }
});
</script>

Upvotes: 1

Views: 145

Answers (1)

Sushanth --
Sushanth --

Reputation: 55740

$(h3)

supposed to be

$('h3') // Missing the quotes

If you want your selector to work, you can assign the variable name.

var h3 = 'h3'; // This should   work as well
if ($(h3).hasClass("6") ){

Upvotes: 5

Related Questions