响应式网站建设哪家公司好,搜索引擎,网页网站制作培训班,做产品类网站有哪些从包含所有段落的集合中删除 id 为 selected 的段落#xff1a; $(p).not(#selected) 定义和用法 not() 从匹配元素集合中删除元素。 语法 1 .not(selector) 参数描述selector字符串值#xff0c;包含用于匹配元素的选择器表达式。语法 … 从包含所有段落的集合中删除 id 为 selected 的段落 $(p).not(#selected) 定义和用法 not() 从匹配元素集合中删除元素。 语法 1 .not(selector) 参数描述selector字符串值包含用于匹配元素的选择器表达式。语法 2 .not(element) 参数描述element一个或多个需要从匹配集中删除的 DOM 元素。语法 3 .not(function(index)) 参数描述function(index)用于检测集合中每个元素的函数。this 是当前 DOM 元素。详细说明 如果给定一个表示 DOM 元素集合的 jQuery 对象.not() 方法会用匹配元素的子集构造一个新的 jQuery 对象。所应用的选择器会检测每个元素不匹配该选择器的元素会被包含在结果中。 请思考下面这个带有简单列表的页面 ullilist item 1/lililist item 2/lililist item 3/lililist item 4/lililist item 5/li
/ul 我们可以向列表项集应用该方法 $(li).not(:even).css(background-color, red); 移除具体的元素 .not() 方法的第二个版本允许我们从匹配集中删除元素假设我们之前已经通过其他手段找到了这些元素。例如设想一个列表已经将 id 应用到其中一个项目中 ullilist item 1/lililist item 2/lili idnotlilist item 3/lililist item 4/lililist item 5/li
/ul 我们可以使用原生的 JavaScript 函数 getElementById() 读取第三个列表项然后把它从 jQuery 对象中删除 $(li).not(document.getElementById(notli)).css(background-color, red); 转载于:https://www.cnblogs.com/lxl57610/p/7284795.html