[英]Get the id using value or label text in jquery
<label class="" for="option1">
<input title="Select All" type="checkbox" id="option1" value="Select All" />
Select All
</label>
现在,我想使用Jquery使用值或标签text =“ Select All”获取输入的ID。 帮我弄清楚,谢谢。
使用属性选择器$('[title="Select All]"]')
:
$(document).ready(function(){ var id = $('[title="Select All"]').attr('id'); console.log(id); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <label class="" for="option1"> <input title="Select All" type="checkbox" id="option1" value="Select All" /> Select All </label>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.