If I have
<p id="target">
<span><sup>$</sup>50</span>
</p>
var $p = $("p#target");
How do I get just the text 50 from $p
i.e. without the dollar sign?
If I have
<p id="target">
<span><sup>$</sup>50</span>
</p>
var $p = $("p#target");
How do I get just the text 50 from $p
i.e. without the dollar sign?
Here's one way:
var clone = $("#target").clone();
clone.find("sup").remove();
var text = clone.text();
Demo: http://jsfiddle.net/ANp9y/
...or, if it's only ever a dollar you need to worry about:
var text = $.trim($("#target").text().replace("$", ""));
You could do this
var a = $('#target span').text();
var b = a.split('$');
alert(b[1]);
Example: http://jsfiddle.net/2mgeC/