I’m having trouble getting the following if statement to work, could some please tell me what i’m doing wrong?
<a id='slink' class='trigger' href='#Sports'>Sport</a>
<a id='elink' class='trigger' href='#Entertainment'>Entertainment</a >
<a id='mlink' class='trigger' href='#Military'>Military</a>
<a id='mocklink' class='trigger' href='#MockUp'>MockUps</a>
$('.trigger').on('click',function(){
if ($(this).attr('id') = 'mocklink') {
alert('hey');
});
You’re missing a closing brace, and you need to make the test in your
ifa boolean. Use the logical “equal” operator (==) instead of the assignment operator (=):