
更多>
最新下载
24小时阅读排行榜
- 1 抖音怎么设置多账号切换 抖音账号快速切换方法解析
- 2 JS中的async/await怎么用?有什么作用?
- 3 UC缓存m3u8转普通视频
- 4 WebStorm调试React应用的环境配置和技巧
- 5 word删除空白区域空白段落 word空白内容清理技巧
- 6 Python中如何处理异步Web请求?
- 7 Python中hashlib的作用 加密哈希模块hashlib的常用算法实现
- 8 学习通小组相册怎么创建 学习通小组相册创建步骤详解
- 9 Python中glob模块 文件路径匹配模块glob的通配符使用技巧
- 10 番茄畅听赚钱是真的吗 番茄畅听收益真实性揭秘
- 11 Python中如何计算三角形的面积?
- 12 怎么安装win7系统 windows7系统怎么安装详细步骤
- 13 度小满金融可靠吗利息高吗 度小满可靠性及利息双重分析
- 14 快速上手通灵义码使用的实用方法
- 15 美团外卖骑手兼职条件有哪些 如何快速通过审核
更多>
最新教程
-
- 麻省理工大佬Python课程
- 9413 2024-05-31
-
- Swoole5 Hyperf3 php8新版本协程框架讲说
- 12001 2024-05-13
-
- 【web前端】Node.js快速入门
- 7877 2024-04-26
-
- 国外Web开发全栈课程全集
- 7804 2024-04-24
-
- Go语言实战之 GraphQL
- 5610 2024-04-19
-
- 550W粉丝大佬手把手从零学JavaScript
- 6420 2024-04-18
js输入关键词生成标签代码
js代码
<script type="text/javascript"> var tagcon = $("tagcon"); var addBox = $("addBox"); var addBtn = addBox.children[1]; var intxt = addBox.children[0]; var divs = tagcon.children; function $(id){ return document.getElementById(id) }//$获取元素函数封装 function crele(ele){ return document.createElement(ele); } //创建元素 function adson(father,son1,son2,son3,clas1,clas2,clas3,clas4,con1,con2){ father.appendChild(son1); father.appendChild(son2); father.appendChild(son3); father.className = clas1; son1.className = clas2; son2.className = clas3; son3.className = clas4; son1.innerHTML = con1; son3.innerHTML = con2; } //输入框聚焦和失焦的效果 intxt.onfocus = function(){ intxt.style.backgroundColor = "#fff"; } intxt.onblur = function () { intxt.style.backgroundColor = "#e3e3e3"; } //点击add按钮添加标签 addBtn.onclick = function () { if(intxt.value != ""){ var newdiv = crele("div"); var newem = crele("em"); var newspan = crele("span"); var newa = crele("a"); if(divs.length == 0){//最新添加的标签在最前边 tagcon.appendChild(newdiv); }else{ tagcon.insertBefore(newdiv,divs[0]) } adson(newdiv,newem,newspan,newa,"tag","tagtxt","move","closetag",intxt.value,"×") intxt.value = ""; }else{ alert("你还没有输入呢!"); } //console.log(links.length); newa.onclick = function () { this.parentNode.style.display = "none"; } } </script>


本站所有资源都是由网友投搞发布,或转载各大下载站,请自行检测软件的完整性!本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!如有侵权请联系我们删除下架,联系方式:admin@php.cn