如何使用 Prototype 迭代特定类的输入
我想迭代属于某个类(例如“required”)的输入数组。我怎样才能遍历它并获取它们的值? 一样的东西
$$('input required').invoke(function(e){
alert(?input value?)
});
像谢谢
I want to iterate over an array of inputs that belong to certain class (eg."required"). How can I traverse it and get their values ? Something like
$('input required').invoke(function(e){
alert(?input value?)
});
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已经很接近了:
所有具有
required
类的输入都将被迭代,并且它们的值将显示到 Firefox 控制台。如果您不使用 Firefox,只需将console.log
更改为alert
即可查看结果。You're close:
All inputs with the class of
required
will be iterated through and their value displayed to the Firefox console. If you don't use Firefox just changeconsole.log
toalert
to see the results.这对我有用。
示例代码:
It works me.
example code: