Using case switch statement to link the a links?
Hello,
I am new to JQuery and have am uncertain how to get this functionality going. Any help would highly be appreciated, please. I have a div name "footer". Within "footer" I have 4 links:
link1, link2, link3, link4
Is there anyway to write a function which will sense which link was clicked and then alert the id of that selected link. I have written the code but am not certain why isn't it working. here is my code.
- $('#footer a').bind('click', function(){
//alert($(this).attr('id'));
var mId = $(this).attr('id');
switch(mId)
{
case 'update':
alert("UPDATE");
break;
case 'print':
alert("PRINT");
break;
case 'save':
alert("SAVE");
break;
case 'help':
alert("HELP");
break;
default:
break;
}
});
- <div id="footer" class="footer">
<ul>
<li id="update"><a href="#">UPDATE MY INFORMATION</a></li>
<li id="print"><a href="#">PRINT</a></li>
<li id="save"><a href="#">SAVE PDF</a></li>
<li id="help"><a href="#">HELP</a></li>
</ul>
</div>