是通过使用伪类选择器来实现的。以下是一些常用的排除子元素的CSS选择器及其解释:
:not(.class)
将选择所有不具有指定类的元素。:first-child
将选择父元素的第一个子元素。:last-child
将选择父元素的最后一个子元素。:nth-child(2)
将选择父元素的第二个子元素。:nth-last-child(2)
将选择父元素的倒数第二个子元素。:only-child
将选择父元素的唯一子元素。这些选择器可以用于排除特定的子元素,从而更精确地选择目标元素。在实际应用中,可以根据具体需求选择适当的选择器来实现排除子元素的效果。
腾讯云相关产品和产品介绍链接地址:
jquery
[] jquery概念
jquery是JS的框架。
JS的函数库。
【】BOM
BOM:Browser Object Model
BOM对象:
1.window:BOM根对象
2.window.navigator 浏览器对象
3.window.location : URL地址对象
4.window.document: 文档对象。
5.window.history 历史对象
【】DOM
DOM根对象:window.document 表示浏览器载入的文档在内存中模型。
DOM模式的格式:树。
每个标记表示一个对象,在树中是一个节点。
1. JS定位一个节点方法
(1)根据ID定位:var div=document.getElementById("id"); 返回一个对象
(2)根据标记名定义:var div=document.getElemenetByTagName("div");
返回对象的数组。
(3) 根据CSS选择器选择对象:
var ob=document.querySelector("css选择器");返回满足选择器的第一个对象
例子:
<input type="text" name="userid" id="userid" />
var userid=document.querySelector("input[name='userid']");
var userid=document.querySelector("#userid");
var userid=document.querySelector("input");
(4) 返回所有的选择器选择的对象:返回对象数组。
document.querySelectorAll("CSS选择器")
【】DOM操作节点对象
1.读/写节点的内容
领取专属 10元无门槛券
手把手带您无忧上云