我有下面的代碼,而不是屬性VAL()的:就拿定製與jQuery
<html>
<head>
<script src="http://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>
其實腳本從value=""
內容。有沒有腳本從我的自定義屬性custAttr=""
獲取代碼的方法?
看看'.attr()' –