What not to do : 
In theory , you could use JavaScript to add important content to a web page.
However, that would be a very bad idea, because there would be no room for graceful degradation.
Visitors lacking the necessary JavaScript support would never see the content. 
 
The markup : HTML, XHTML, or HTML5
For the markup, its up to you whether to use HTML or XHML.
The important thing is that whichever document type you choose, the markup validates to the 
specified DOCTYPE declaration.
 
With XHTML, all the tags must be closed. That includes stand-alone elements like <img> and <br>
which must be written with a closing slash: <img /> and <br />
To use the XHTML DOCTYPE, you include this at the begining of your document :
<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strick.dtd" >
Another option that you may like even better is to use the HTML5 DOCTYPE. The HTML5 DOCTYPE is 
very simple (just 15 characters) :
<!DOCTYPE html>
   
You can create useful scripts like these using just a handful of DOM methods and porperties.
Having well-structured markup is an important prerequisite when you are enhancing content 
with DOM scripts.
            As a recap, these are the most useful methods for retrieving information from a document :
  • getElementById
  • getElementsByTagName
  • getElementsByName
  • getAttribute
            These are the most useful methods for attaching information to a document :
  • createElement
  • createTextNode
  • appendChild
  • insertBefore
  • setAttribute
By combining those methods, you can create very powerful DOM scripts.
Always remember to use JavaScript to enhance the content of your documents, rahter than 
creating any core content directly with the DOM.

Enhacing the content with JavaScript的更多相关文章

  1. How to get a DOM element's ::before content with JavaScript?

    How to get a DOM element's ::before content with JavaScript? https://stackoverflow.com/questions/443 ...

  2. javascript 技巧总结积累(正在积累中)

    1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...

  3. Meta标签详解(HTML JAVASCRIPT)

    Meta标签详解,在网上转的,希望对大家有用 您的个人网站即使做得再精彩,在“浩瀚如海”的网络空间中,也如一叶扁舟不易为人发现,如何推广 个人网站,人们首先想到的方法无外乎以下几种: ● 在搜索引擎中 ...

  4. javascript基础部分

    javascript基础部分 1  数据类型: 基础数据类型(通过typeof来检测):Number,string,undefined,null,boolean,function typeof只能检测 ...

  5. javascrit2.0完全参考手册(第二版) 第1章第1节 在XHTML文档中增加javascript

    通常,向文档中增加script脚本使用<script>元素,在HTML中增加脚本的方式有4中: (1)放到<script></script>块中: (2)<s ...

  6. Android WebView和JavaScript交互

    JavaScript在现在的网页设计中用得很多,Android 的WebView可以载入网页,WebView也设计了与JavaScript通信的桥梁.这篇主要介绍一下WebViewk控件如何和Java ...

  7. Javascript:浮动的导航条

    代码主体及说明 Javascript部分: /** * @函数名:flexScroll * @功能:滚动超出一定高度,指定元素悬浮 * @两个参数:target_id:目标元素id;topEle:限定 ...

  8. webview与JavaScript之间的交互

    据说WebView的强大之处就是能和JavaScript进行交互调用. 参考博客:http://droidyue.com/blog/2014/09/20/interaction-between-jav ...

  9. Android 中Java和JavaScript交互入门

    如何实现JavaScript 和java 交互 实现Java和js交互十分便捷.通常只需要以下几步. WebView开启JavaScript脚本执行 WebView设置供JavaScript调用的交互 ...

随机推荐

  1. ASP.NET MVC 音乐商店 - 4. 数据访问

    上一次,我们使用了模拟的数据从控制器发送到视图模板.现在,我们开始使用真正的数据库,在这个教程中,我们将指导如何使用 SQL Server Compact 版的数据库,它经常被称为 SQL CE, 来 ...

  2. [SVN]TortoiseSVN工具培训2─SVN的基本概念和工作模式

    1.SVN是什么? TortoiseSVN,属于集中式版本控制工具,是Subversion版本控制系统的一个免费SVN开源客户端,可以对文件版本进行统一管理和控制:文件保存在中央版本库,您可以将文件恢 ...

  3. 如何让MVC和多层架构和谐并存(二)

    上一节说了一些笼统的东西,这节说一些实际的操作. 1.取列表.这是一个新闻列表:         对应MVC的model是: public class NewsListModel { /// < ...

  4. java compiler没有1.8怎么办

    选择第一个点击安装,安装完成后,重启eclipse,打开java compiler 就可以选择1.8了. 成功:  扫个红包吧! Donate捐赠 如果我的文章帮助了你,可以赞赏我 1 元,让我继续写 ...

  5. 微信小程序又一爆炸功能上线-云开发

    云开发介绍 开发者可以使用云开发开发微信小程序.小游戏,无需搭建服务器,即可使用云端能力. 云开发为开发者提供完整的云端支持,弱化后端和运维概念,无需搭建服务器,使用平台提供的 API 进行核心业务开 ...

  6. Spark master节点HA配置

    Spark master节点HA配置 1.介绍 Spark HA配置需要借助于Zookeeper实现,因此需要先搭建ZooKeeper集群. 2.配置 2.1 修改所有节点的spark-evn.sh文 ...

  7. 简单的Nodejs模块

    说千遍,道万遍,不如动手做一遍,我们实现一个node所谓的模块 看下上面的图,了解一下模块自始至终的一个流程,首先是创建模块,也就是一个入口的js文件,里面加了一些特定的功能,然后导出这个模块, ex ...

  8. 2018.7.27 Json与Java相互转换

    Json.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" page ...

  9. 【转】基于JavaMail的Java邮件发送

    http://blog.csdn.net/xietansheng/article/details/51673073 http://blog.csdn.net/xietansheng/article/d ...

  10. machine learning学习笔记

    看到Max Welling教授主页上有不少学习notes,收藏一下吧,其最近出版了一本书呢还,还没看过. http://www.ics.uci.edu/~welling/classnotes/clas ...