阅读背景:

用jQuery取自定义属性而不是val()

来源:互联网 

I have the following code:

我有以下代码:

<html>
<head>
    <script src="https://code.jquery.com/jquery-latest.pack.js"></script>
</head>
<body>
<select name="size">
    <option custAttr="0" value="0" disabled selected>Value ↓</option>
    <option custAttr="10" value="10">AAA (10)</option>
    <option custAttr="20" value="20">BBB (20)</option>
    <option custAttr="30" value="30">CCC (30)</option>
</select>

<label class="result"></label>

<script>
$(document).ready(function() {
    $('select').on('change', function() {
        $('.result').text(
            $('select[name=size]').val()
        );
    });
});
</script>
</body>
</html>
<html>
<



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: