Javascript 在不同站点中从我的站点进行搜索
我想在不同的网站(不同的网站:example.com)上搜索我的表单 搜索词(xxx)需要指向: 一位朋友给我写了这个函数:Javascript 在不同站点中从我的站点进行搜索,javascript,html,forms,Javascript,Html,Forms,我想在不同的网站(不同的网站:example.com)上搜索我的表单 搜索词(xxx)需要指向: 一位朋友给我写了这个函数: function SearchKeyword() { var searchKeyword=""; if($('.txtSearch').eq(0).val() !="Search") //mobile searchKeyword = trim( $('.txtSearch').eq(
function SearchKeyword()
{
var searchKeyword="";
if($('.txtSearch').eq(0).val() !="Search") //mobile
searchKeyword = trim( $('.txtSearch').eq(0).val() );
if($('.txtSearch').eq(1).val() !="Search")
searchKeyword = trim( $('.txtSearch').eq(1).val() );
// searchKeyword = trim($('#txtSearch').val());
if(searchKeyword != ""){
document.location.href = 'search___' + searchKeyword + '.html';
}
}
如何将其与此Html表单连接
<div class="wrap">
<div class="search">
<input type="text" class="searchTerm" placeholder="What are you looking for?">
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
我认为我的朋友没有将代码连接到该站点,而这个JS通常是
谢谢你的帮助!
John您需要将输入元素的类从
“searchTerm”
更改为“txtSearch”
。
或者将函数中的所有
'txtSearch'
更改为'searchTerm'
尚未工作,需要将函数连接到站点,但如何连接?您所说的“将函数连接到站点”是什么意思?你是说在页面上添加脚本?要添加它,请将函数放在'
标记之间,就在'
标记之前。否。我想在不同的网站搜索。(不同网站:example.com)搜索词(xxx)需要指向:脚本上没有