Jquery怎么获取select选中项 自定义属性的值
1个回答
展开全部
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Ball</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$ (function ()
{
$ ("select").change (function ()
{
alert ($ (this).find ("option:selected").attr ("abc"));
})
})
</script>
</head>
<body>
<select>
<option abc="a">111</option>
<option abc="d">222</option>
<option abc="f">333</option>
<option abc="dfd">444</option>
</select>
</body>
</html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Ball</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$ (function ()
{
$ ("select").change (function ()
{
alert ($ (this).find ("option:selected").attr ("abc"));
})
})
</script>
</head>
<body>
<select>
<option abc="a">111</option>
<option abc="d">222</option>
<option abc="f">333</option>
<option abc="dfd">444</option>
</select>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询