How can I execute each switch statement case in JS?

No switch needed:

<a class="profile">...</a>


$(".profile").on("click",function(e) { 
  e.preventDefault(); // cancel link
  var idx = $(this).index(); // assuming links in a container   
  $('#contactPicture').attr('src', contacts[idx].picture);

Please note the following:

How do i style a span to look like a link without using javascript?

Browse More Popular Posts

Leave a Comment