jQuery className woes

我的未来我决定 提交于 2019-12-02 07:04:38

You can call the attr method to get any underlying attributes on the element you need.

$('.toggle:checked').attr('class').match(/toggle\-.+?\b/); 

className is a standard DOM member, not a jQuery wrapper property. Either access through $('something')[0].className or jQuery $('something').attr('class'), but you can't mix them.

You appear to have multiple radio​s without a shared name? That won't work, they'll all act ast separately checkable fields. All radio controls that belong together need to have the same name (but different value​s) and be placed within the same form.

Don't you need an Id on all items jQuery is to look at?

$('.toggle:checked').hasClass('toggle-2');
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!