在Plain Ole的Javascript中,我是否需要使用循环遍历单选按钮/复选框以查看是否已选中它们,或者是否有更简单的方法?
Yes. It may be most helpful to...
document.getElementsByClassName
document.getElementsByTagName
(though, the tag is the input
tag, so you may get other elements as well) However, that is just getting the elements; but as you've stated, you will still need to iterate through each one to do whatever comparison you like. jQuery will allow you to do this kind of thing more easily, but "Plain Ole' Javascript" cannot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.