这个 focusout() 是jQuery中的一个内置方法,用于从选定元素中移除焦点。 语法:
null
$(selector).focusout(function);
参数: 它接受一个参数“函数”,该参数将在执行淡出方法后执行。 返回值: 它返回失去焦点的选定元素。 显示focusout()方法工作的jQuery代码:
< html > < head > < script </ script > <!-- jQuery code to show the working of this method --> < script > $(document).ready(function() { $("div").focusin(function() { $(this).css("background-color", "green"); }); $("div").focusout(function() { $(this).css("background-color", "#FFFFFF"); }); }); </ script > < style > div { border: 2px solid black; width: 50%; padding: 20px; } input { padding: 5px; margin: 10px; } </ style > </ head > < body > <!-- click inside the field focusin will take place and when click outside focusout will take place --> < div > Enter name: < input type = "text" > < br > </ div > </ body > </ html > |
输出: 点击输入字段内部后,focusin将开始工作-
点击输入字段外部后,focusout将生效。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END