How does jquery get the value of a select selected item custom property?
HTML Code
<select id= "DDL" onchange= "Ddl_change (This)" "> <option value=" "emoney=" "gmoney=" > Japan card </option > <option value= "102" emoney= "5" gmoney= "+" > Month card </option> <option value= "103" emoney= "518" gmoney= "+/--"-------- "> Annual card </option><select>
JScript Code
function Ddl_change (obj) {alert ($ ("#ddl"). attr ("Emoney")); That's undefined}
How does jquery get the value of a select selected item custom property?
It's undefined!!.
How to get the value of the custom attribute "Emoney" in the Select selected item!??
------Solution--------------------------------------------------------
$ ("#ddl"). Find ("option:selected"). attr ("Emoney");
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Document</title>
<script type= "Text/javascript" src= "Jquery-1.8.1.min.js" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (' #lev '). Change (function () {
$ (' #lev2 '). html (' <option value= "1" lev2= "1" >1</option><option value= "2" lev2= "2" >2</option ><option value= "3" lev2= "3" >3</option><option value= "4" lev2= "4" >4</option><option Value= "5" lev2= "5" >5</option> ");
Alert ($ (' #lev '). Find (' option:selected '). attr (' Lev '));
$ (' #lev '). Find (' option:selected '). attr (' Selected ', ' selected ');
});
$ (' #lev2 '). Change (function () {
Alert ($ (' #lev2 '). Find (' option:selected '). attr (' Lev2 '));
$ (' #lev2 '). Find (' option:selected '). attr (' Selected ', ' selected ');
});
})
</script>
<body>
<select id= "Lev" >
<option value= "1" lev= "1" >1</option>
<option value= "2" lev= "2" >2</option>
<option value= "3" lev= "3" >3</option>
<option value= "4" lev= "4" >4</option>
<option value= "5" lev= "5" >5</option>
</select>
<select id= "Lev2" >
</select>
</body>
How jquery Gets the value of the Select Selected custom property