// 清空搜索框内容 function clearText() { var x = document.getElementById('keyword'); if (x.defaultValue == x.value) { x.value = ''; } else if (x.value == '') { x.value = x.defaultValue; } x.style.border = 'dotted'; x.style.color = 'blue'; }

// 添加 logo 文本节点 var element = document.getElementById('site_title'); var he = document.createElement('li'); var ht = document.createTextNode('点击logo进入我的小镇'); he.appendChild(ht); element.appendChild(he);

// 添加超链接元素节点 var y = document.createElement('a'); y.innerHTML = '蓝玫瑰'; y.href = 'http://baike.haosou.com/doc/871058-920943.html'; var weekly = document.getElementById('weekly'); weekly.appendChild(y);

JavaScript 函数实现搜索框清空、添加 logo 文本节点和超链接节点

原文地址: https://www.cveoy.top/t/topic/n47K 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录