window.onload = function () {
// 切换搜索引擎
function chang(){
let dwdd = document.querySelector(".seach2 i").className;
let qurl ="
https://www.baidu.com/s?ie=utf-8";
let qname = "wd";
if (dwdd == "icon-baidu") {
} else if (dwdd == "icon-google") {
qurl ="
https://www.google.com/search?hl=zh-CN";
qname ="q";
} else if (dwdd == "icon-S") {
qurl ="
https://www.sogou.com/web";
qname ="query";
} else if (dwdd == "icon-bing") {
qurl ="
https://cn.bing.com/search";
qname ="q";
}
document.getElementById("form").action = qurl;
document.getElementsByClassName("wd")[0].name = qname;
}
let seach1 = document.getElementsByClassName("seach1")[0];
let seach2 = document.getElementsByClassName("seach2")[0];
let seach3 = document.getElementsByClassName("seach3")[0];
// 切换搜索图标
seach2.addEventListener("click", select);
function select() {
let wd = document.getElementsByClassName("wd")[0].value;
if (wd == "" || wd == null) {
seach3.style.display = "block";
this.style.display = "none";
seach1.style.boxShadow = "10px 10px 5px #888888";
} else {
document.getElementById("form").submit();
}
}
let s3 = seach3.getElementsByTagName("i");
for(let i=0;i<s3.length;i++){
s3[i].addEventListener("click", select3,true);
}
function select3(event){
// console.log(event);
let evn = event.srcElement||event.target;
document.querySelector(".seach2 i").className = evn.className;
document.querySelector(".seach2 i").style.color = evn.style["color"];
seach2.style.display = "block";
seach3.style.display = "none";
seach1.style.boxShadow = "";
chang();
}
//菜单点击
let menu = document.getElementById("menu");
menu.addEventListener("click",function (event) {
menu.classList.toggle("on");
document.getElementsByClassName("list")[0].classList.toggle("closed");
});
document.getElementById("content").addEventListener("click",function (event) {
if(menu.classList.contains("on")){menu.classList.remove('on');}
document.getElementsByClassName("list")[0].classList.add('closed');
seach3.style.display = "none";
seach2.style.display = "block";
seach1.style.boxShadow = "";
},true);
};
这是主页的样式的 css
原件在这里:
链接:
https://pan.baidu.com/s/1PSr8tdMWBTFKLVQLt4hFtQ 提取码: s147 复制这段内容后打开百度网盘手机 App,操作更方便哦
我就想在这个搜索的主页多个 dogedoge 的搜索按钮
是不是简单在} else if 后 仿写就好了 不用动其他地方呀
请教下诸位