How to select a span with multiple classes and placed inside an anchor?

后端 未结 1 1574
余生分开走
余生分开走 2021-01-28 15:39

I\'m in a situation where I need to bind a click event to a span (placed inside an achor having multiple classes) based on the classes applied to it.

For eg:

相关标签:
1条回答
  • 2021-01-28 16:16

    Multiple classes should be selected like this:

    $('span.c3.c4').parents('a').click(function (e) { alert("clicked!"); });
    

    See a working demo here > http://jsfiddle.net/JeG3A/

    0 讨论(0)
提交回复
热议问题