jQuery的 - 选择标签 - 获得所选元素的属性 [英] jQuery - select tag - get attribute of the selected element
本文介绍了jQuery的 - 选择标签 - 获得所选元素的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有得到属性的一种方式 - 比如从'选择'标签的选择的选项'相对' - ?即
Is there a way of getting the attribute - such as 'rel' from the selected option of the 'select' tag - i.e.?
<select name="menu" id="menu">
<option value="1" rel="123">Option 1</option>
<option value="2" rel="124">Option 2</option>
</select>
任何想法?
推荐答案
您可以只使用:选择
过滤器
下面是一个小提琴: http://jsfiddle.net/jomanlk/ECAea/
$('#menu').change(function(){
alert($(this).find('option:selected').attr('rel'));
});
这篇关于jQuery的 - 选择标签 - 获得所选元素的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文