从< span>获取复选框值用jquery [英] Getting checkbox value from <span> with jquery
问题描述
http://ghinda.net/css-toggle-switch/bootstrap.html
Im使用上述css文件和代码进行切换开关。我想检查检查了哪个结果,但我从未使用过使用< span>< / span>
标签的内容。
Im using the above css files and code to make a toggle switch. I want to check which result is checked but I have never worked with something that uses the <span></span>
tags.
我试图搜索找到我的问题的答案,但我没有运气搜索正确的事情,所以我决定问。
I have tried searching to find the answer to my question but I just have no luck searching the right thing so I decided to ask.
我的代码:
<label class="checkbox toggle well" onclick="">
<input id="view" type="checkbox" checked />
<span>
Spotlight
<span>Off</span>
<span>On</span>
</span>
<a class="btn btn-primary slide-button"></a>
</label>
如何获得与所选择的值相对应的值?
How do i get a value which corresponds with which ones selected?
如果你可以将我重定向到一个带有答案的帖子或回答我的问题,我会非常感谢。提前感谢。
If you can redirect me to a post with the answer or answer my question I would be very grateful. Thank you in advance.
推荐答案
jQuery:
$('#view:checked') ? "it's on" : "it's off";
您不必触摸那些跨度以获得选中的值。
You don't have to touch those spans in order to get the checked value.
这篇关于从< span>获取复选框值用jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!