Summary: DOM modification techniques
Modifying an existing element
Modifying attributes
src of an <img>:imgEl.src = "http://www.dogs.com/dog.gif";
setAttribute method, like so:imgEl.setAttribute("src", "http://www.dogs.com/dog.gif");
removeAttribute - like to remove the disabled attribute off a button, effectively enabling it:imgEl.removeAttribute("disabled");
Modifying styles
style property of the element, and setting the corresponding property. For example, to change the color:headingEl.style.color = "hotpink";
headingEl.style.backgroundColor = "salmon";
Modifying class names
className property:mainEl.className = "warning";
mainEl.className += " warning";
classList functionality instead:mainEl.classList.add("warning");
Modifying inner HTML / text
innerHTML:mainEl.innerHTML = "cats are the <strong>cutest</strong>";
textContent instead:mainEl.textContent = "cats are the cutest";
Creating elements from scratch
createElement:var imgEl = document.createElement("img");
appendChild on the target parent element:document.body.appendChild(imgEl);
Summary: DOM modification techniques的更多相关文章
- 高性能Javascript(2) DOM编程
第三部分 DOM编程 文档对象模型(DOM)是一个独立于语言的,使用XML和HTML文档操作的应用程序接口(API).在浏览器中,主要与HTML文档打交道,在网页应用中检索XML文档也很常见.DOM ...
- Techniques for HA IT Management
7. Techniques That Address Multiple Availability Requirements Redundancy Hardware Redundancy Example ...
- 给Extjs的GridPanel增加“合计”行(转)
再Google,找到一个看似写的比较好的 http://www.cnblogs.com/over140/archive/2009/05/06/1449892.html 期间主要部分也是借鉴官方论坛上的 ...
- CCNET+MSBuild+SVN实时构建的优化总结
本文不是介绍如何使用CCNET+MSBuild+SVN构建自动编译系统,相关的内容可以从很多地方获取,可以再园子里搜一下. 随着我们的SVN库日益壮大,容量达到10G,几十G 甚至更大时,我们发现自动 ...
- Offset Management For Apache Kafka With Apache Spark Streaming
An ingest pattern that we commonly see being adopted at Cloudera customers is Apache Spark Streaming ...
- (转) Ensemble Methods for Deep Learning Neural Networks to Reduce Variance and Improve Performance
Ensemble Methods for Deep Learning Neural Networks to Reduce Variance and Improve Performance 2018-1 ...
- JavaFX WebView and WebEngine Tutorial教程
JavaFX WebView JavaFX WebView is a mini browser that is called as an embedded browser in JavaFX appl ...
- ViewContainerRef 动态创建视图
Angular DOM 操作 相关的APIs和类: 查询DOM节点 template variable ref: 模版变量引用,相当于react中的ref ViewChild: 查询DOM,返回单个元 ...
- Review: JQuery
1.DOM access with jQuery 1 $("h1"); //select all the h1s 2 $("#heading"); // sel ...
随机推荐
- 缓存cache和缓冲区buffer
一.cache 1.cache的定义.从宏观上讲,缓存是处理速度不匹配的问题.可以是静态缓存(内存缓存.磁盘缓存).动态缓存(前端的缓存)和数据库缓存.另一个角度,从CPU来看,可以是寄存器和内存之间 ...
- Java语言的魅力
Java语言的简介 Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承.指针等概念,因此Java语言具有功能强大和简单易用两个特征.Java语言作为静态面 ...
- PAT-1154(Vertex Coloring )+map使用+vector建图+set的使用
Vertex Coloring PAT-1154 #include<iostream> #include<cstring> #include<string> #in ...
- vue之better-scroll详解及封装
在我们的h5或移动端网页开发中,常常会需要实现滚动加载数据,等需求,而在开发中原生开发往往会带来意想不到的问题,因此我们引入better-scroll来帮我们实现流畅的滚动效果. 什么是better- ...
- 手把手教你DNS劫持挂马
出品|MS08067实验室(www.ms08067.com) 本文作者:BlackCat(Ms08067内网安全小组成员) 首先学习DNS劫持之前,务必要了解下DNS是个什么玩意. DNS(域名系统) ...
- 卷积神经网络学习笔记——轻量化网络MobileNet系列(V1,V2,V3)
完整代码及其数据,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/DeepLearningNote 这里结合网络的资料和Mo ...
- java基础详解-集合
一.集合组成 java集合主要由Map和Collection组成,Collection主要类图如下(图片来源于网络,懒得画图): 从上图中能很明显的看出来Collection下主要是Set.List和 ...
- Apache Pulsar 在能源互联网领域的落地实践
关于 Apache Pulsar Apache Pulsar 是 Apache 软件基金会顶级项目,是下一代云原生分布式消息流平台,集消息.存储.轻量化函数式计算为一体,采用计算与存储分离架构设计,支 ...
- 攻防世界 reverse 新手练习区
1.re1 DUTCTF IDA shift+F12 查看字符串 DUTCTF{We1c0met0DUTCTF} 2.game ZSCTF zsctf{T9is_tOpic_1s_v5ry_int7r ...
- APIView里如何获取HTTP里的数据
request.data.get() 获取post方法表单里的数据 request.post.get() 获取post方法表单里的数据 request.GET.get() 获取URL里的数据 r ...