Jquery单击按钮添加一个下拉列表,并且下拉列表添加一个onchange事件,这个怎么弄,在线等。
解决方案 »
- 进来看看怎么实现的??
- 100分求助。谁能把这个代码给我搞下来。
- 帮忙看下这段代码?--javascript中自动添加下拉框数据
- 誰能幫我把這個用htm寫的表格改為svg?100的高分請高人!
- 这个为什么会出错啊 help me
- 求教高手!!!!如何单击按钮就停止网页中的一个js?
- !!高手进!!怎么才能让asp得到js脚本处理后的结果?
- <div>的使用问题
- 请问怎样在web页中禁止鼠标右键???
- 请教一下关于document.form1.select1.options[]的问题,请帮忙!!!
- 做网页游戏。现在用js 的话。后台不考试。那前端用什么组合最好?
- 使用javascript 放大、缩小图片
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#btn_add").click( function() {
$("#demo").html('<select><option value="111">111</option><option value="222">222</option></select>');
});
$("#demo select").live('change', function() {
alert($(this).val());
});
});
</script>
</head><body>
<input type="button" id="btn_add" value="添加下拉列表" />
<div id="demo"></div>
</body>
</html>
$("#demo select").live('change', function() {
alert($(this).val());
});
假如不是#demo而是生成的一个单元格里面找这个select怎么找
<!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=gbk" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#btn_add").click( function() {
$("td:eq(1)").html('<select><option value="111">111</option><option value="222">222</option></select>');
});
$("select").live('change', function() {
alert($(this).val());
});
});
</script>
</head><body>
<input type="button" id="btn_add" value="添加下拉列表" />
<table>
<tr>
<td>1-1</td>
<td>1-2</td>
</tr>
</table>
</body>
</html>
楼主学学jquery吧
http://www.w3school.com.cn/jquery/index.asp
你这个单元格是现成的,我的是这样的,单元格也是生成的,
var newTr2 = bank_table.insertRow();
newTr2.bgColor = 'white';
newTr2.id = 'tr'+k;
var newTd20 = newTr2.insertCell();
var newTd21 = newTr2.insertCell();
var newTd22 = newTr2.insertCell();
var newTd23 = newTr2.insertCell();newTd21.innerHTML =$("#bankNameGenerate").html()+"<input type='hidden' name='mumMemberAccount["+k+"].bankHeadName' size='35' value='' class='required max-length-25 input' alt='交易银行'> <font color='red'>*</font>";现在是怎么在newTd21 这里面找select,为select赋onchange,我脚本不怎么样,感谢回答。
newTd21.getElementsByTagName('select')[0].onchange = function() {
alert(this.value);
}
//$("#bankNameGenerate").html() 这是select吗?这是select的html代码