admin管理员组文章数量:1404767
How can I get the content of h2 tag in Prototype framework?
I tried this:
alert($$('h2').value());
but it haven't done anything.
thx,
Oded
edit: thank you for the fast and great support!
How can I get the content of h2 tag in Prototype framework?
I tried this:
alert($$('h2').value());
but it haven't done anything.
thx,
Oded
edit: thank you for the fast and great support!
Share Improve this question edited Dec 27, 2011 at 17:08 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Feb 1, 2011 at 20:15 Oded HarthOded Harth 4,4069 gold badges37 silver badges62 bronze badges 03 Answers
Reset to default 3The $$
returns an Array.
I you only want the first <h2>
, then access it at index 0
.
alert($$('h2')[0].innerHTML);
Or you can iterate over the Array using prototypejs' .each()
method.
$$('h2').each(function(el,i) {
alert(el.innerHTML);
});
$$(el) creates an array. You need to iterate over each value, or if you just want the first h2, then use .first()
alert($$('h2').first().value());
Check out the API http://globalmoxie./bm~doc/prototype-160-api.pdf
Shouldnt you use .html(). jQuery is using this, i think prototype would use something similar.
Try this: alert($('h2').innerHTML);
本文标签: javascripthow to get value of h2 elementStack Overflow
版权声明:本文标题:javascript - how to get value of h2 element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744805712a2626134.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论