Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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_Onblur - Fatal编程技术网

Javascript 如何捕获父元素中的模糊事件

Javascript 如何捕获父元素中的模糊事件,javascript,jquery,onblur,Javascript,Jquery,Onblur,我想实现的是,当我从group1输入移动到group2输入时,会捕捉到模糊事件,因此我可以执行其他操作。模糊事件不是传播给父母吗 $(文档).ready(函数(){ $(“[data id=container]”。在(“blur”,function()上){ 警报(“母公司捕获模糊”); }); }); 第一组 第2组 我无法完全理解您的问题,但假设您希望在从第1组更改为第2组时进行某种形式的验证,我正在编写以下代码。以下代码段是一个通用表单,您可以根据需要进行自定义

我想实现的是,当我从group1输入移动到group2输入时,会捕捉到模糊事件,因此我可以执行其他操作。模糊事件不是传播给父母吗


$(文档).ready(函数(){
$(“[data id=container]”。在(“blur”,function()上){
警报(“母公司捕获模糊”);
});
});
第一组
第2组

我无法完全理解您的问题,但假设您希望在从第1组更改为第2组时进行某种形式的验证,我正在编写以下代码。以下代码段是一个通用表单,您可以根据需要进行自定义

                <input type="text" id="one" onblur="validate">
                <input type="text" id="two" onblur="validate">
                <input type="text" id="three" onblur="validate">
                <script type="text/javascript>
                    function validate()
                    {
                        var a = document.getElementById("one");
                        var b = document.getElementById("two");
                        var c = document.getElementById("three");
                        if (b.hasFocus() == true) //checks if the second input box has focus
                        {
                            alert("Value of the focused field is "+a.value); //this will give you the value in the first input box
                        }
                        else if (c.hasFocus() == true) //checks if the third input box has focus
                        {
                            a.focus(); //this will get the focus back on the first input box
                        }
                    }

                </script>


我无法完全理解您的问题,但假设您希望在从组1更改为组2时进行某种形式的验证,我正在编写以下代码。以下代码段是一个通用表单,您可以根据需要进行自定义

                <input type="text" id="one" onblur="validate">
                <input type="text" id="two" onblur="validate">
                <input type="text" id="three" onblur="validate">
                <script type="text/javascript>
                    function validate()
                    {
                        var a = document.getElementById("one");
                        var b = document.getElementById("two");
                        var c = document.getElementById("three");
                        if (b.hasFocus() == true) //checks if the second input box has focus
                        {
                            alert("Value of the focused field is "+a.value); //this will give you the value in the first input box
                        }
                        else if (c.hasFocus() == true) //checks if the third input box has focus
                        {
                            a.focus(); //this will get the focus back on the first input box
                        }
                    }

                </script>


请参见第1组和第2组是同级,而不是父级->子级请参见第1组和第2组是同级,而不是父级->子级