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:

$('#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();
链接地址: http://www.djcxy.com/p/47072.html

上一篇: 微小的非对称密码实现来验证下载

下一篇: JQuery的$(element).text()的Prototype等价物是什么?