您现在的位置是:首页 > 电脑技术查询 > web开发

怎么点击文字执行js

编辑:chaxungu时间:2022-10-10 23:24:17分类:web开发

如何点击文字执行js

如何在文本里输入内容,然后点击百度搜索执行搜索

<style>
.one{
width:100px;
height:20px;
border:1pxsolid#FF1001;
}
</style>
<script>document.getElementById('bd').onclick=function(e){varv=document.getElementById('search').value;window.open('http://www.baidu.com/s?wd='+v);}

</script>

<inputname="textfield"type="text"id="search"/>

<divid="bd"class="one">百度搜索</div>

------解决方案--------------------
直接用百度的api
http://help.baidu.com/question?prod_en=search&class=500&id=1000664
------解决方案--------------------
脚本拿到容器下边
------解决方案--------------------
获取文本参数,通过url跳转到百度搜索,你还有什么问题,你不都是这么做的。