JS空格事件选定下拉框的值,并获取选定的值? js 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $("select:selected").text();//用JQuery 这个应该用onkeypress去实现然后获取空格键键位码判断键位码是不是空格键然后在获取select下面option值就ok了 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script>function spaceEvt(e){ var evt=e||window.event; if(evt.keyCode=='32') alert(document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].text);}</script></head><body onkeyup="spaceEvt(event)"><select id="sel" style="width:100px;" size="15"> <option value="11">1</option> <option value="22">2</option> <option value="33">3</option> <option value="44">4</option> <option value="55">5</option> <option value="66" selected="selected">6</option> <option value="77">7</option> <option value="88">8</option> <option value="99">9</option> <option value="10">10</option></select></body></html>写一个小例子挺简单的! 自己解决了,不过还是要谢谢你们了://JS空格事件选取Select项<br /><br /><select onkeypress="changeChars(window.event.keyCode,this,'otherFocusId')"> <option value="baoma">宝马</option> <option value="benchi">奔驰</option></select><script type="text/javascript"> function changeChars(code, obj, otherFocusId) { if (code == 32) { document.getElementById("" + otherFocusId + "").focus(); } document.getElementById("" + otherFocusId + "").value = obj.value; }</script><input type="text" id="otherFocusId" /> 跪求jquery ui 日期datetimepicker控件使用 extjs中tabpanel如何释放内存 如何通过一个页面获取本机某个目录的文件列表 页面中有多个table,怎样一次性指定第一个table1所有的td中的文字都使用同一个css svg的导出图片问题 怎样限制输入框只能输入数字??? src 的问题 如何通过javascript将ie最大化? 请问alert有些什么参数? 哪位大侠知道在Netscape6.0里如何移动、隐藏层对象<div>? 这段加密JS怎么解~! 求助:js某个输入框中回车提交事件,用户在页面输入后按回车进行搜索查询
$("select:selected").text();//用JQuery
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function spaceEvt(e){
var evt=e||window.event;
if(evt.keyCode=='32')
alert(document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].text);
}
</script>
</head>
<body onkeyup="spaceEvt(event)">
<select id="sel" style="width:100px;" size="15">
<option value="11">1</option>
<option value="22">2</option>
<option value="33">3</option>
<option value="44">4</option>
<option value="55">5</option>
<option value="66" selected="selected">6</option>
<option value="77">7</option>
<option value="88">8</option>
<option value="99">9</option>
<option value="10">10</option>
</select></body>
</html>写一个小例子挺简单的!
//JS空格事件选取Select项<br />
<br />
<select onkeypress="changeChars(window.event.keyCode,this,'otherFocusId')">
<option value="baoma">宝马</option>
<option value="benchi">奔驰</option>
</select>
<script type="text/javascript">
function changeChars(code, obj, otherFocusId) {
if (code == 32) {
document.getElementById("" + otherFocusId + "").focus();
}
document.getElementById("" + otherFocusId + "").value = obj.value;
}
</script>
<input type="text" id="otherFocusId" />