Hello All - Out of curiousty which of the following code is more efficient (if neither, what would be the best way?)
Backstory - Building a small image carousel and the code in question has to do with the controls (prev, pause/play, next)
<ul class="controls">
<li> <a href="#" class="prev"> Previous Image </a> </li>
<li> <a href="#" class="pause"> Pause </a> </li>
<li> <a href="#" class="next"> Next Image </a> </li>
</ul>
// inside document.ready()
$(".controls a").click(function() {
var cur_class = $(this).attr("class");
if (cur_class == "pause") {
// do something
} else if (cur_class == "prev") {
// do something
} else if (cur_class == "next") {
// do something
}
)};
// OR THIS
$(".controls a.prev").click(function() { /* do something */ });
$(".controls a.pause").click(function() { /* do something */ });
$(".controls a.next").click(function() { /* do something */ });
Thanks M.