开发者

Selecting child elements with jQuery

I'm trying to quickly select an element on my page using jQuery. This is the code so far:

$('#row-58开发者_高级运维708 > 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." Of course, there is no name tag, but you see the point.


$('.row').find('strong').html('tesing');

Check working example at http://jsfiddle.net/gZA8E/


I take it you want to change Skin name to testing. If so use this:

$('#row-58708 strong').html('testing')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜