How jquery Gets the value of the Select Selected custom property

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.