jqery用document.getElementById获取的值显示为[object HTMLInputElement] wd='+ document.getElementById('content').value+ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 已经说过了,用document.getElementById('content').value获取的值为空。 你的input输入框内有值么?如果有值的话再看看会不会是id冲突了 如果你的input输入框有值得话,应该是name冲突了 id 要唯一 input框中要有值 LZ是要在点链接的时候才取文本枢的值jQuery('#searchcontent').append('<div><a href="#" target="_blank" onclick="this.href=\'http://www.baidu.com/s?wd=\'+document.getElementById(\'content\').value">百度</a></div>'); 看来是我没说清楚。这段的目的是读取搜索框里输入的字符,然后搜素框旁边放一个按钮,这个按钮可以读取搜索框内的内容,然后用按钮内置的另外一个搜素引擎搜索。但是我在搜索框内输入字符后,点这个按钮获取的值要么是空,要么是Undefind。 你得重新绑定啊。<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><script>$(document).ready(function(){ jQuery('#searchcontent').append('<div><a href="http://www.baidu.com/s?wd='+ document.getElementById('content').value+'" target="_blank">百度</a></div>'); $("#content").bind("change",function(){ $("a").attr("href","http://www.baidu.com/s?wd="+ document.getElementById('content').value+""); });});</script></head><body><div id="searchcontent"><input type="text" name="wd" id="content" maxlength="100" class="s_ipt" autocomplete="off"></div></body></html> ie8开发人员工具无法使用,按f12任务栏里出现任务,但是窗体不弹出 求教一个关于Google Map API的问题 jquery 支持安卓等手机web开发不? 提示js缺少对象,求大神指点 javascript提取url参数难题,高分请帮忙 请教关于乱码和自适应高度 帮忙看看代码有什么问题...急 JS实现动态添加表单 急:如何控制confirm()确认窗口的字体颜色和大小 关于confirm的问题 DOM相关的javascript问题 怎样获取cookie的过期时间?
jQuery('#searchcontent').append('<div><a href="#" target="_blank" onclick="this.href=\'http://www.baidu.com/s?wd=\'+document.getElementById(\'content\').value">百度</a></div>');
这段的目的是读取搜索框里输入的字符,然后搜素框旁边放一个按钮,这个按钮可以读取搜索框内的内容,然后用按钮内置的另外一个搜素引擎搜索。但是我在搜索框内输入字符后,点这个按钮获取的值要么是空,要么是Undefind。
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
jQuery('#searchcontent').append('<div><a href="http://www.baidu.com/s?wd='+ document.getElementById('content').value+'" target="_blank">百度</a></div>');
$("#content").bind("change",function(){
$("a").attr("href","http://www.baidu.com/s?wd="+ document.getElementById('content').value+"");
});
});</script>
</head>
<body>
<div id="searchcontent">
<input type="text" name="wd" id="content" maxlength="100" class="s_ipt" autocomplete="off">
</div>
</body>
</html>