怎么获取select的值? <script>$(function(){var checkTextbill=jQuery("#send_color").find("option:selected").text();})</script> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 必需在select加载完后才能获取到值<select id="#send_color""没有# 绑定onchange事件,获取val(),就可以了 <select id="#send_color"" name="#send_color"" style="color:Black;"">红色部分去掉 id和name 后面放# 这个习惯不好 如果是获取value 还是用$(id).val(); 你这样写获取的是“白色”、“黑色”还有因为页面加载是至上而下 如果非要放第一行的话改成 页面加载完成后去获取值 比如:<script>var checkTextbill;$(function(){ checkTextbill=jQuery("#send_color").find("option:selected").text();});</script> 楼上综合起来就是正解,<script>$(function(){var checkTextbill=$("#send_color").find("option:selected").text();})</script><select id="send_color"" name="send_color"" style="color:Black;""> <option value="-1">请选择y</option> <option value="1" >黑色</option> <option value="2" >白色</option> <option value="3" >红色</option></select> 初始让第一行选中<script>$(function(){var checkTextbill=$("#send_color").find("option:selected").val();})</script><select id="send_color"" name="send_color"" style="color:Black;""> <option value="-1" selected="true">请选择y</option> <option value="1" >黑色</option> <option value="2" >白色</option> <option value="3" >红色</option></select> <script src="jquery.js"></script><script>$(function(){$("#send_color").change(){alert($("#send_color option:selected").text());}})</script><select id="send_color"" name="send_color"" style="color:Black;""> <option value="-1">请选择y</option> <option value="1" >黑色</option> <option value="2" >白色</option> <option value="3" >红色</option></select> 试过了,不行,不知道为什么,jquery也导入了 把你的代码以HTML格式粘贴出来 你的dom对象id都搞错了。。多了#号<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script><script>$(function(){alert($("#send_color option:selected").text());})</script><select id="send_color"" name="send_color"" style="color:Black;""> <option value="-1">请选择y</option> <option value="1" >黑色</option> <option value="2" >白色</option> <option value="3" >红色</option></select> 想问一个很简单的关于JS代码内置和外链的问题。 我写了一个js的类,不过想在类中调用本身的方法,应该怎么写呢》? JavaScript中的$符号 想给连接加一个target=_blank pager-taglib中文参数问题 关于这段代码的files[0]求助 js进行数字计较的问题 如何在多行文本框<textarea>中使用"Ctrl+Enter"换行???? 请问如何捕捉页面中光标位置的偏移量,想实现一个书签功能 真是怪啊!是不是bug啊? 怎么才能知道是在移动终端上浏览网页? 前端需要怎样的软技能?
<select id="#send_color""没有#
红色部分去掉 id和name 后面放# 这个习惯不好 如果是获取value 还是用$(id).val(); 你这样写获取的是“白色”、“黑色”
还有因为页面加载是至上而下 如果非要放第一行的话
改成 页面加载完成后去获取值 比如:
<script>
var checkTextbill;
$(function(){
checkTextbill=jQuery("#send_color").find("option:selected").text();
});</script>
<script>
$(function(){
var checkTextbill=$("#send_color").find("option:selected").text();
})
</script>
<select id="send_color"" name="send_color"" style="color:Black;"">
<option value="-1">请选择y</option>
<option value="1" >黑色</option>
<option value="2" >白色</option>
<option value="3" >红色</option>
</select>
<script>
$(function(){
var checkTextbill=$("#send_color").find("option:selected").val();
})
</script>
<select id="send_color"" name="send_color"" style="color:Black;"">
<option value="-1" selected="true">请选择y</option>
<option value="1" >黑色</option>
<option value="2" >白色</option>
<option value="3" >红色</option>
</select>
<script>
$(function(){
$("#send_color").change(){
alert($("#send_color option:selected").text());
}
})
</script>
<select id="send_color"" name="send_color"" style="color:Black;"">
<option value="-1">请选择y</option>
<option value="1" >黑色</option>
<option value="2" >白色</option>
<option value="3" >红色</option>
</select>
把你的代码以HTML格式粘贴出来
<script>
$(function(){
alert($("#send_color option:selected").text());
})
</script>
<select id="send_color"" name="send_color"" style="color:Black;"">
<option value="-1">请选择y</option>
<option value="1" >黑色</option>
<option value="2" >白色</option>
<option value="3" >红色</option>
</select>