这个 不是() 是jQuery中的一个内置函数,与 过滤器() 方法此函数将返回所有与具有特定“id”或“class”的选定元素不匹配的元素。 语法:
null
$(selector).not(A)
选择器是不被选择的选定元素。 参数: 它接受一个参数“a”,它是指定元素的“id”或“class”。 返回值: 这将返回除所选元素之外的所有元素。
< html > < head > jquery/3.3.1/jquery.min.js"></ script > < script > $(document).ready(function() { $("p").not(".main").css("background-color", "green"); }); </ script > </ head > < body > < p class = "main" >Hello !!!</ p > < p class = "main" >Welcome to</ p > < p >GeeksforGeeks.!!!</ p > </ body > </ html > |
输出: 代码#2: 在下面的示例中,id为“main”的所有段落元素在背景中以绿色突出显示。
< html > < head > jquery/3.3.1/jquery.min.js"></ script > < script > $(document).ready(function() { $("p").filter("#main").css("background-color", "green"); }); </ script > </ head > < body > < p id = "main" >GeeksforGeeks.!!!</ p > < p id = "main" >Hello !!!</ p > < p >This is not() method of jQuery.!!!</ p > </ body > </ html > |
输出:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END