jQuery - getting custom attribute from selected option របៀបចាប់យក attribute ពី selected option

http://jumnuoy.blogspot.com/2013/09/jquery-getting-custom-attribute-from.html

<html>
<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>
Demo: click here 


<html>
<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>
Demo: click here 

0 comments:

Post a Comment

Followers

រឿង ដែលខានមើលមិនបាន

Contact us

Name

Email *

Message *

Your Language

Online

Copyright 2009 Simplex Celebs All rights reserved Designed by www.sruol9.com