开发者

jQuery, click element inside clickable element

开发者 https://www.devze.com 2023-02-22 21:40 出处:网络
I have HTML syntax as followed : <tab开发者_JS百科le> <tr> <td id="click1">

I have HTML syntax as followed :

<tab开发者_JS百科le>
  <tr>
    <td id="click1">
      <a href="somelink.html" id="click2">
        here's the link
      </a>
    </td>
  </tr>
</table>

and I have jquery syntax like this

$('td#click1').ajaxify();
$('a#click2').fancybox();

My problem is, if I click the #click2 then the #click1 is selected too.

How can I make it only select #click2 without calling #click1?


$('a#click2').click(function(event){

    event.stopPropagation();

})

you can call stopPropagation, to prevent event bubbling up the DOM tree.

0

精彩评论

暂无评论...
验证码 换一张
取 消