$(function(){
var a = $(".product li:contains('Available')").clone();
a.find('span').remove();
alert(a.html());
});
Sample : http://jsfiddle.net/wrFAh/8/
EDIT : The above solution is expecting the LI
element to have only one type of HTML element other than the number to retrieved, that is the span
, If you are adding a div
to the li, this wont work.
To handle this, I would wrap the Price
in the HTML in a span
and access it to avoid such problems.
So my HTML will look like
<ul class="product">
<li><span>Available:</span><span class="price">123</span></li>
<li><span>Code:</span><span class="price">123</span></li>
</ul>
And script would be
$(function(){
var a = $(".product li:contains('Available')").find(".price").html();
alert(a);
});
Sample http://jsfiddle.net/wrFAh/12/