在包含输入的输入文本框中输入字符后,移动到新页面

Move to a new page after entering a character in input textbox holding the input

本文关键字:输入 移动 新页面 字符 包含 文本      更新时间:2023-09-26

我想在我的网页中实现类似于谷歌搜索页面的东西。链接 http://www.google.com 在页面中间显示搜索字段,键入字符后,它会移动到页面顶部,其中包含输入的输入。

如果有人可以演示使用jquery/javascript或html来实现这一点,那就太好

我只是为你准备了一个小脚本,以获得一个想法。处理它并在此过程中读取jquery事件。这应该可以帮助您入门,http://jsfiddle.net/epinapala/uZ8xv/2/

顺便说一句,Gogole不会在即时搜索上重定向您。 T 移动div,这个例子是一个非常小的原型来演示相同的内容。

<div class="block">
    <input id="ip" type="text" />
    <div class="res">NULL</div>
</div>  
div {
  position:absolute;
  left:50px;
  width:90px;
  height:90px;
  margin:5px;
  top:100px;
}​

var d = false;
$("#ip").keyup(function(){
    if(d ==false){
    $(".block").animate({"top": "-=50px"});
        d= true;
    }
    var v =$(this).val();
    $(".res").html("Search results for " + v );
});

使用 keypressappendTo

<div style="height:30px;" id="divMain">
    Move entire form below here on search
</div>
<br />
<div style="height:90px;" id="divOther">
<br />Some text...
<form id="frmSubmit">  
  Search: <input type="text" id="txtSearch" /><br />
  <input type="submit" value="Submit" />
</form>
</div>

j查询:

$("#txtSearch").keypress(function() {
    $("#frmSubmit").appendTo("#divMain");
    $('#txtSearch').focus();
});​

最后:

js小提琴示例