Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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_Html - Fatal编程技术网

如何使用javascript选择器

如何使用javascript选择器,javascript,jquery,html,Javascript,Jquery,Html,javascript中是否有一种方法可以在另一个选择器(如jQuery)中选择选择器: $("section h1").html(); 您可以找到的最接近的可能是document.querySelector或document.querySelector all。但是要小心,因为支持仅限于现代浏览器。您可以找到的最接近的可能是document.querySelector或document.queryselectoral。但要小心,因为支持仅限于现代浏览器。在可用时实际使用。问题是,你自己永远无法

javascript中是否有一种方法可以在另一个选择器(如jQuery)中选择选择器:

$("section h1").html();

您可以找到的最接近的可能是
document.querySelector
document.querySelector all
。但是要小心,因为支持仅限于现代浏览器。

您可以找到的最接近的可能是
document.querySelector
document.queryselectoral
。但要小心,因为支持仅限于现代浏览器。

在可用时实际使用。问题是,你自己永远无法模仿jQuery提供的所有优点(例如,
filter()
find()
children()
parent()
map()
not()
,以及使用伪类的能力)

这足以抓住第节中的h1元素:

var e = document.querySelector("section h1");

阅读此答案。

在可用时实际使用。问题是,你自己永远无法模仿jQuery提供的所有优点(例如,
filter()
find()
children()
parent()
map()
not()
,以及使用伪类的能力)

这足以抓住第节中的h1元素:

var e = document.querySelector("section h1");


阅读此答案。

您还可以执行以下操作。。。然而,有更简单的方法

参见jsfiddle


您还可以执行以下操作。。。然而,有更简单的方法

参见jsfiddle


document.queryselectoral()?在另一个选择器中选择一个选择器的确切含义是什么?“在另一个选择器中选择一个选择器,如jQuery中的选择器:”这是一个绕口令。我想他指的是在
中选择
的非jQuery方式。您可能需要类似var selector=$(“section h1”).html()的内容。find('selector')); $(选择器).blablabla:)document.queryselectoral()?在另一个选择器中选择一个选择器是什么意思,确切地说?”在另一个选择器中选择一个选择器,如在jQuery中:“这是一个绕口令。我想他指的是在
中选择
的非jQuery方式。您可能需要类似var selector=$(“第h1节”)的内容.html().find('selector')$(选择器)。布拉布拉:)