Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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 在Jquery上下文菜单中,如何识别右键单击的元素是否为href? $('#divis').bind(“上下文菜单”,函数(e){ e、 预防默认值(); $(#自定义菜单”).css({top:e.pageY+“px”,left:e.pageX+“px”}); $('#a1')。单击(函数(){ 警报($(this.attr('href')); document.execCommand('unlink',false,null); }); });_Javascript_Jquery_Html - Fatal编程技术网

Javascript 在Jquery上下文菜单中,如何识别右键单击的元素是否为href? $('#divis').bind(“上下文菜单”,函数(e){ e、 预防默认值(); $(#自定义菜单”).css({top:e.pageY+“px”,left:e.pageX+“px”}); $('#a1')。单击(函数(){ 警报($(this.attr('href')); document.execCommand('unlink',false,null); }); });

Javascript 在Jquery上下文菜单中,如何识别右键单击的元素是否为href? $('#divis').bind(“上下文菜单”,函数(e){ e、 预防默认值(); $(#自定义菜单”).css({top:e.pageY+“px”,left:e.pageX+“px”}); $('#a1')。单击(函数(){ 警报($(this.attr('href')); document.execCommand('unlink',false,null); }); });,javascript,jquery,html,Javascript,Jquery,Html,这里显示的是li a href属性ie。“# “我想知道,当我在内容可编辑div(divi)中右键单击时,我想知道我右键单击了什么元素是a href或任何其他html元素ot标记。然后我想执行取消链接选项功能,但我被困在这里请帮助我您可以使用方法 <div id="divis" contenteditable="true" style="width:250px; height:200px;border:1px solid"> <a href="http://ww

这里显示的是li a href属性ie。“# “我想知道,当我在内容可编辑div(divi)中右键单击时,我想知道我右键单击了什么元素是a href或任何其他html元素ot标记。然后我想执行取消链接选项功能,但我被困在这里请帮助我您可以使用方法

    <div id="divis" contenteditable="true" style="width:250px; height:200px;border:1px solid">
    <a href="http://www.w3schools.com">Visit W3Schools</a></div>
    <div id="custom-menu">  
    <ol>
    <li><a id ="a1" href="#">Removelink</a> </li>
    <li><a href="#">Reply All</a> </li>
    </ol></div>


$('#divis').bind("contextmenu", function(e) {
e.preventDefault();

$("#custom-menu").css({ top: e.pageY + "px", left: e.pageX + "px" }).show(100);
$('#a1').click(function(){
    alert($(this).attr('href'));
    document.execCommand('unlink',false,null);
});
});

我怎么知道我右键点击了这个窗口?你以15秒的优势击败了我:D
$(e.target).is('a#a1')
('#id').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Left mouse button pressed');
            break;
        case 2:
            alert('Middle mouse button pressed');
            break;
        case 3:
            if($(e.target).is('a#a1'))
               .................

            break;
        default:
            alert('You have a strange mouse');
    }
});