本文介绍了使用jQuery获取自定义标签值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<select id="selTest">
<option custom="123" value="abc">111</option>
<option custom="456" value="def">222</option>
<select>
...使用jQuery,如何获取option.custom,其中option.value = selTest.val()
...using jQuery, how do I get option.custom where option.value=selTest.val()
换句话说:如果selTest.val = def,则$ x = 456(我试图将custom的值转换为$ x)
in other words: if selTest.val = def, then $x=456 (I'm trying to get the value of custom into $x)
推荐答案尝试一下:
var selectedCustomValue = $("select#selTest option:selected").attr("custom");更多推荐
使用jQuery获取自定义标签值
发布评论