开发者

readAttribute by classname in Prototype javascript

开发者 https://www.devze.com 2023-01-26 01:57 出处:网络
I am having a HTML like <a href=\"yourpath/controller/views/username\" class=\"classname\">username</a>

I am having a HTML like

<a href="yourpath/controller/views/username" class="classname">username</a>

How to read the attribute href's value by classname using the Prototype.js.

Ple开发者_开发百科ase give some suggestions.


$$('.classname')[0].readAttribute('href');

Note that $$ will always return an array.


$$('.classname').pluck('href');

This will return an array of href values in case you need more than one.


$$('.className')[0].readAttribute('href')
0

精彩评论

暂无评论...
验证码 换一张
取 消