Given the following snippet:
<div id="myDiv">
This is my text <span>with a span</span>
</div>
JQuery can get the interior string with:
$('#myDiv').text();
Is there a more intuitive way in Prototype than:
$('myDiv').pluck('innerHTML').first().stripTags();
Hum, doesn't
$('myDiv').innerHTML.stripTags();
work ?
Edit: if you really want a text()
method in Prototype, you can do so :
Class.extend(Element, {
text: function(element) {
return element.innerHTML.stripTags();
}
};
and then use it like this :
var txt = $('myDiv').text();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With