搜索框
<form method="get" id="form">
<div class="input-group" style="margin-top: 100px;margin-left: 500px;margin-right: 500px;">
<span class="input-group-btn">
<button id="baidu" class="btn btn-default" type="submit">百度一下</button>
</span>
<input id="search" type="text" class="form-control" placeholder="Search for..." name="q">
<span class="input-group-btn">
<button id="google" class="btn btn-default" type="submit">谷歌一下</button>
</span>
</div><!-- /input-group -->
</form>
js代码
<script type="text/javascript">
var search = document.getElementById("search");
var baidu = document.getElementById("baidu");
var google = document.getElementById("google");
var form = document.getElementById("form");
$(function(){
$("#baidu").click(function(){
baiduurl = 'https://www.baidu.com/s';
$("#search").attr("name","wd");
$("#form").attr("action",baiduurl);
});
});
$(function(){
$("#google").click(function(){
googleurl = 'https://www.google.com/search';
$("#search").attr("name","q");
$("#form").attr("action",googleurl);
alert(googleurl);
});
});
</script>