开发者

Jquery change value of span tag - reference from another div

So my html code is:

<div class="product-details">
    <div class="availability in-stock">
          Availability: <span>In stock</span>
    </div>
</div>

I would like to use Jqu开发者_开发问答ery to change the span value of "in stock". I am somewhat new to Javascript and Jquery, so how would I change that span value without it having an id to reference.

Many thanks in advance!


$('.in-stock span').html("your new string");

http://jsfiddle.net/hQqtU/


$('.product-details .availability span').text('foo');

Fiddle: http://jsfiddle.net/maniator/EryVF/


What you are looking for is either the text() or the html() like so:

$('.availability span').html('This is what you want to change it to');

Here is an example: JsFiddle Demo

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜