读书人

jquery里针对insertCell()里的input值

发布时间: 2012-10-23 12:12:22 作者: rapoo

jquery里针对insertCell()里的input值如何获取其value值
<script>
var myTable = document.getElementById("myTable2");


if (myTable != null) {
var myRow = myTable.insertRow();
myRow.insertCell().innerHTML = '<input type="text" ID="tPrice" name="textDepotID" style="width:120px;border-width:0px;text-align:center;border-style:none" readonly="readonly" value="' + txtSellprice + '"/>';
}
</script>

我要取得该行的该input,id为tPrice的value值,我用jquery的话。这么写
var a=$(this).children("#tPrice").val()
不知道为啥,取不到值。

下面为参考代码。
$("#myTable2 tr ").live({
"keydown": function (e) {
var Key = e.keyCode || e.which || e.charCode;

if (Key == 98) {//小键盘-号
// alert(Key);
var k = window.showModalDialog("altershow.htm", window, "dialogWidth:270px;status:no;dialogHeight:176px");
if (k != null)//这里k值我是可以确定返回值没错。


$(this).children("#tPrice").val() = k;//这里似乎获取的inputID错误了。

}
}
})


[解决办法]
不管你的K有没有错,你那语句是确实错了

JScript code
var a=$(this).children("#tPrice").val() 

读书人网 >JavaScript

热点推荐