[英]Selecting child elements with jQuery
I'm trying to quickly select an element on my page using jQuery. 我正在尝试使用jQuery快速选择页面上的元素。 This is the code so far:
到目前为止,这是代码:
$('#row-58708 > div.cell name > div > strong').html('tesing');
This is the markup: 这是标记:
<div id="row-58708" class="row">
<div class="cell name">
<div>
<strong>Skin name</strong>
</div>
</div>
</div>
I know what I've written is far off the mark, but I can't work it out anyhow... could anyone lend a hand? 我知道我写的东西还差得远,但是我还是无法解决……任何人都可以伸出援手吗? Cheers!
干杯!
You're actually not far off, you're just not using the multiple class selector correctly: 您实际上相距不远,只是没有正确使用多类选择器:
$('#row-58708 > div.cell.name > div > strong').html('tesing');
In your version, you have div.cell name
, which literally means "select all name
tags that are within a div of class cell." 在您的版本中,您具有
div.cell name
,其字面意思是“选择类单元格div中的所有name
标签”。 Of course, there is no name tag, but you see the point. 当然,没有名称标签,但是您明白了。
$('.row').find('strong').html('tesing');
I take it you want to change Skin name to testing . 我认为您要将“ 皮肤名称”更改为“ testing” 。 If so use this:
如果是这样,请使用以下命令:
$('#row-58708 strong').html('testing')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.