【发布时间】:2017-08-01 21:08:59
【问题描述】:
我想用 jquery 选择这个:
.single-product > .product-buybox-big > .col-sm-6
您可以在例如本页:click me。
.single-product 在 body 类上。 .product-buybox-big 可以在#wrapper-fluid > #main > .container > .col-sm-9 > #content 和.col-sm-6 元素中找到.product-buybox-big 中的行下方。
现在这是我必须处理的。每个产品网站的内容都不同。但我也知道,在每个产品网站上都有上面提到的三个类:.single-product、.product-buybox-big 和.col-sm-6。我怎样才能为这样的 javascript 选择它们?
我的 jQuery 总是为这个返回 null:
var x = document.querySelector("single-product > product-buybox-big > col-sm-6");
非常感谢您的帮助! 亲切的问候
【问题讨论】:
-
你缺少类选择器
. -
发布你的html代码
-
如果您使用 JQuery,请使用
$(..selector..)函数来选择元素
标签: javascript jquery html jquery-selectors