jQuery - rule for “does not contain element”

前端 未结 2 665
余生分开走
余生分开走 2020-12-28 15:08

I want to create a rule to target the a element in the following:

2条回答
  •  醉话见心
    2020-12-28 16:00

    $('#root a').click(function(e) {
        if ( $(this).parents('ul').length > 1 ) {
           e.preventDefault(); // cancel action for anchors inside of #root who have multiple parent list elements 
        }
    });
    

    Change logic per requirement.

提交回复
热议问题