wd='+ document.getElementById('content').value+

解决方案 »

  1.   

    已经说过了,用document.getElementById('content').value获取的值为空。
      

  2.   

    你的input输入框内有值么?如果有值的话再看看会不会是id冲突了
      

  3.   

    如果你的input输入框有值得话,应该是name冲突了
      

  4.   

    id 要唯一  input框中要有值
      

  5.   

    LZ是要在点链接的时候才取文本枢的值
    jQuery('#searchcontent').append('<div><a href="#" target="_blank" onclick="this.href=\'http://www.baidu.com/s?wd=\'+document.getElementById(\'content\').value">百度</a></div>');
      

  6.   

    看来是我没说清楚。
    这段的目的是读取搜索框里输入的字符,然后搜素框旁边放一个按钮,这个按钮可以读取搜索框内的内容,然后用按钮内置的另外一个搜素引擎搜索。但是我在搜索框内输入字符后,点这个按钮获取的值要么是空,要么是Undefind。
      

  7.   

    你得重新绑定啊。<!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>