Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript LI上的绑定事件不在LI-jQuery内的锚标记上_Javascript_Jquery_Html - Fatal编程技术网

Javascript LI上的绑定事件不在LI-jQuery内的锚标记上

Javascript LI上的绑定事件不在LI-jQuery内的锚标记上,javascript,jquery,html,Javascript,Jquery,Html,我有这种HTML <li class="one-reference per-reference ui-draggable" item-id="8" style="position: relative;"> <a class="moduleItemTitle" href="http://localhost/derrickpang/index.php?option=com_k2&amp;view=item&amp;id=8">Knee pains&l

我有这种HTML

<li class="one-reference per-reference ui-draggable" item-id="8" style="position: relative;">
     <a class="moduleItemTitle" href="http://localhost/derrickpang/index.php?option=com_k2&amp;view=item&amp;id=8">Knee pains</a>
     <span class="moduleItemDateCreated">Written on Wednesday, 19 October 2016 05:58</span>
     <span class="moduleItemHits">Read 393 times</span>
     <div class="clr"></div>
 </li>
  • 写于2016年10月19日星期三05:58 读393遍
  • 我已在所有LIs上绑定事件,每个参考类

    我不想在单击带有class
    的标签时调用函数
    openRefModal
    。moduleItemTitle
    我只想在
    href
    中打开该链接,作为锚定标签的正常行为

    这是我试过的

    jQuery(“.per reference”).bind(“单击”,openRefModal);
    
    jQuery(“.per reference.moduleItemTitle”).unbind(“单击”,openRefModal)只需为
    a
    标签
    moduleItemTitle
    类添加以下代码即可

    jQuery(".per-reference").bind("click", openRefModal);
    jQuery(".per-reference .moduleItemTitle" ).click(function( event ) {
      event.stopPropagation();
    });
    
    现在,
    click事件中释放了一个
    标记


    以下是有关

    的详细信息,类似的方法应该可以奏效:

    $('.per reference')。单击(函数(事件){
    event.preventDefault();
    if(event.target.className!==“moduleItemTitle”){
    //你想在这里干什么就干什么
    }
    });
    $('.per reference>.moduleItemTitle')。单击(函数(事件){
    event.preventDefault();
    document.location=event.target.href;
    });
    
    我的答案对你的问题有效吗?