Tutorial :What is the Prototype equivalent of JQuery's $(element).text()?


Given the following snippet:

<div id="myDiv">    This is my text <span>with a span</span>  </div>      

JQuery can get the interior string with:


Is there a more intuitive way in Prototype than:



Hum, doesn't


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();  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »