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 ...
随机推荐
- 双重检验锁模式为什么要使用volatile?
并发编程情况下有三个要点:操作的原子性.可见性.有序性. volatile保证了可见性和有序性,但是并不能保证原子性. 首先看一下DCL(双重检验锁)的实现: public class Singlet ...
- HDOJ-1069(动态规划+排序+嵌套矩形问题)
Monkey and Banana HDOJ-1069 这里实际是嵌套矩形问题的变式,也就是求不固定起点的最长路径 动态转移方程为:dp[i]=max(dp[j]+block[i].h|(i,j)∈m ...
- POJ-2236(并查集)
Wireless NetWork POJ-2236 需要注意这里的树的深度需要初始化为0. 而且,find函数需要使用路径压缩,这里的unint合并函数也使用了优化(用一开始简单的合并过不了). #i ...
- 解决:layUI数据表格+简单查询
解决:layUI数据表格+简单查询 最近在用layui写项目,在做到用户查询时,发现在layui框架里只有数据表格,不能增加查询.于是自己摸索了一下,写个笔记记录一下. 我想要的效果: 1.定义查询栏 ...
- dubbo实战之三:使用Zookeeper注册中心
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- 漏洞复现-Flask-SSTI服务端模板注入
0x00 实验环境 攻击机:Win 10 0x01 影响版本 Python利用的一些静态框架 0x02 漏洞复现 (1)实验环境:docker运行的vulhub漏洞环境 首先,可直接访问到页面的显 ...
- Oracle数据库搬家牵扯出的一些知识点记录
Oracle数据库迁移过程中的一些记录 工作原因,对开发服务器的数据库进行了迁移,实际执行操作之前查了一下迁移oracle数据库的可行方案,最后用了 exp/imp 进行导出导入(这个比较简单),以及 ...
- gpfdist原理解析
gpfdist原理解析 前言:gpfdist作为批量向postgresql写入数据的工具,了解其内部原理有助于正确使用以及提供更合适的数据同步方案.文章先简要介绍gpfdist的整体流程,然后针对重要 ...
- Java实现解压缩文件和文件夹
一 前言 项目开发中,总会遇到解压缩文件的时候.比如,用户下载多个文件时,服务端可以将多个文件压缩成一个文件(例如xx.zip或xx.rar).用户上传资料时,允许上传压缩文件,服务端进行解压读取每一 ...
- Spark SQL中Not in Subquery为何低效以及如何规避
首先看个Not in Subquery的SQL: // test_partition1 和 test_partition2为Hive外部分区表 select * from test_partition ...