使用jQuery获取自定义标签值 [英] getting a custom tag value using jquery

查看:414
本文介绍了使用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获取自定义标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆