https://jumnuoy.blogspot.com/2013/09/jquery-getting-custom-attribute-from.html
<html>Demo: click here
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#one').change(function(){
var value = $('select#one option:selected').attr('id');
alert(value);
});
});
</script>
</head>
<body>
<select id="one">
<option value="1" id="yeah, it's work">one</option>
<option value="12" id="this's from 2 option">two</option>
</select>
<!--<input type="submit" id="btn" value="save" />-->
</body>
</html>
<html>Demo: click here javascript Jquery
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#one').change(function(){
var value = $('select#one option:selected').attr('id');
alert(value);
});
});
</script>
</head>
<body>
<select id="one">
<option value="1" id="yeah, it's work">one</option>
<option value="12" id="this's from 2 option">two</option>
</select>
<!--<input type="submit" id="btn" value="save" />-->
</body>
</html>
0 comments:
Post a Comment