简单的 jQuery 选择器只选择 Chrome 中的第一个元素..? [英] Simple jQuery selector only selects first element in Chrome..?
问题描述
我对 jQuery 有点陌生,所以请原谅我过于密集.我想通过 Chrome 的 JS 控制台选择特定页面上的所有 I'm a bit new to jQuery so forgive me for being dense. I want to select all 然而,当我这样做时,我得到以下输出: Yet when I do this, I get the following output: jQuery 不是应该返回带有 Isn't jQuery supposed to return an array of elements with the 这是有问题的网站:http://www.w3schools.com/html/html_tables.asp 我想补充一点,当我在 Chrome 控制台中输入一个 jQuery 函数时,我没有得到一个 jQuery 对象.我得到一个普通的 HTML 元素.我的 Chrome 的设置/配置方式一定有问题. I'd like to add that when I type a jQuery function into Chrome console, I do NOT get a jQuery object back. I get a plain HTML element. Something must be wrong with the way my Chrome is set-up/configured. 如果网页上没有 jQuery,当然也没有其他代码给 If jQuery isn't present on the webpage, and of course no other code assigns something to 您可以使用 You can achieve what you want with 要知道页面是否包含jQuery,可以在控制台中执行 To know if the page contains jQuery, you can execute 此外,还有浏览器插件可以在每个网页中注入 jQuery. Also, there are browser addons to inject jQuery in every webpage. 这篇关于简单的 jQuery 选择器只选择 Chrome 中的第一个元素..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 元素:
<td>
elements on a particular page via Chrome's JS console:$('td')
<td>Apples</td>
<td>
标签的元素数组吗?为什么我只看到符合此条件的第一个元素?<td>
tag? Why am I only seeing the first element that matches this criteria?推荐答案
$
赋值,Chrome 的 JS 控制台会分配 $
document.querySelector()
的快捷方式.$
, Chrome's JS console assigns $
a shortcut to document.querySelector()
.$$()
实现您想要的功能,它由控制台分配给 document.querySelectorAll()
的快捷方式.$$()
, which is assigned by the console a shortcut to document.querySelectorAll()
.jQuery
.要知道 jQuery 是否分配给 $
,您可以执行 $().jquery
如果是这种情况,它将返回 jQuery 版本.jQuery
in the console. To know if jQuery is assigned to $
, you can execute $().jquery
which will return jQuery version if that's the case.
登录
关闭