Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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 两个同时发生的事件_Javascript_Jquery_Events - Fatal编程技术网

Javascript 两个同时发生的事件

Javascript 两个同时发生的事件,javascript,jquery,events,Javascript,Jquery,Events,我在这个页面上使用了一个JS代码 当我按下十字符号时,会发生两个事件(模糊和单击),但只运行模糊代码。我需要contra,点击交叉码。 我该怎么做 $(函数(){clickOnLink();}); 函数clickOnLink(){ $(“span.link”)。在({ 单击:函数(){ var linkId=$(this).text().replace(/\D+/g,“”); var id=$(this.attr(“id”); var idNum=$(this.attr(“id”).repla

我在这个页面上使用了一个JS代码 当我按下十字符号时,会发生两个事件(模糊和单击),但只运行模糊代码。我需要contra,点击交叉码。 我该怎么做


$(函数(){clickOnLink();});
函数clickOnLink(){
$(“span.link”)。在({
单击:函数(){
var linkId=$(this).text().replace(/\D+/g,“”);
var id=$(this.attr(“id”);
var idNum=$(this.attr(“id”).replace(/\D+/g,”);
var idType=“link_”+$(this.attr(“id”).replace(/\d+/g,”);
var result=“ПццБца链接+✘";
$(this).replaceWith(函数(索引,oldHTML){
返回结果;
});
$(“输入”).focus();
clickOnCross();
blurOnInput();
}
});
};
函数clickOnCross(){
$(“span.cross”)。在({
单击:函数(){
$(this.remove();
}
});
};
函数blurOnInput(){
$(“输入”)。在({
模糊:函数(){
$(this.prev().remove();
$(this.next().remove();
var idName=$(this.attr(“id”);
var idNum=$(this.attr(“id”).replace(/\D+/g,”);
var idType=“link_”+$(this.attr(“id”).replace(/\d+/g,”);
$(this).replaceWith(函数(索引,newHTML){
var linkId=$(this.val();
var linkIdDb=“link”+$(this.val();
$.get(“handlers/send_link.php”,{
id:idNum,
答案:idType,
linkid:linkIdDb}
);
var result=“Пцццаa链接”+linkId+”;
返回结果;
});       
单击联机();
}
});
};

在调用
单击事件之前,在
鼠标向下
触发的
模糊
事件上移除十字,当您希望触发
单击
事件时,
DOM中不再有
十字
元素


如果你想在十字符号的
点击
事件上绑定某个内容,不要将其从
输入
字段的
模糊
事件的
DOM中删除。

你应该格式化你的代码,我会编辑它,但这对iPhone来说是个麻烦
$(function(){clickOnLink();});
    function clickOnLink(){
        $("span.link").on({
            click: function(){
        var linkId = $(this).text().replace(/\D+/g,"");
        var id = $(this).attr("id");
        var idNum = $(this).attr("id").replace(/\D+/g,"");
        var idType = "link_"+$(this).attr("id").replace(/\d+/g,"");
        var result = "<span class='link'>Переход на link</span> <input     type='text' id='"+id+"' value='"+linkId+"'> <span><span class='plus'>+</span><span    class='cross'>✘</span></span>";
        $(this).replaceWith(function(index, oldHTML){
        return result;
        });
        $("input").focus();
        clickOnCross();
        blurOnInput();
        }
    });
};
function clickOnCross(){
$("span.cross").on({
    click: function(){
        $(this).remove();
     }
});
};
function blurOnInput(){
$("input").on({
    blur: function(){
        $(this).prev().remove();
        $(this).next().remove();
        var idName = $(this).attr("id");
        var idNum = $(this).attr("id").replace(/\D+/g,"");
        var idType = "link_"+$(this).attr("id").replace(/\d+/g,"");
        $(this).replaceWith(function(index, newHTML){
        var linkId = $(this).val();
        var linkIdDb = "link"+$(this).val();
        $.get("handlers/send_link.php", { 
            id: idNum, 
            ans: idType,
            linkid: linkIdDb }
        );
        var result = "<span class='link' id='"+idName+"'>Переход на link"+linkId+". <a href='#link"+linkId+"'>⇗</a></span>";
        return result;
        });       
        clickOnLink();
    }
});
};