div+css 输入框问题

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:52:52
messageDiv.innerHTML ="<input type=\"text\" name=\"inputContent\" id=\"inputContent\" size=\"40\">";
var bottom_menu = "<input name=\"s_submit_btn\" id=\"s_submit_btn\" value=\"确定\" type=\"button\" class=\"rb1\" style=\"position:relative;left:-100px\" onclick=\"submitInput();\" /><input name=\"s_cancel_btn\" id=\"s_close_btn\" value=\"取消\" type=\"button\" class=\"rb1\" style=\"position:relative;left:-80px\" onclick=\"closeMessageBox();\" />";

当单击“确定”按钮时,在submitInput()方法中使用JQuery这样$("#inputContent").val();却取不到文本框中的值(DOM方式同样取不到值),哪位告诉这个问题出在哪里?已经是第二次遇到这种问题,把html文本赋值给innerHTML后再使用对象id就取不到相应的值了,这是为什么?

这样拿值也行呀

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>拿值</title>
<script language="javascript">
function unvalue(){
var values = document.getElementById("inputContent").value;
document.getElementById("inputContents").value = values;
}
</script>
</head>

<body>
<input type="text" id="inputContent" ><br />
<input type="button"onclick="unvalue()" value="点击拿值" /><br />
<input type="text" id="inputContents" readonly="true" >
</body>
</html>