HTML5深入浅出教学篇之五

介绍

HTML 5: 元素的通用属性

元素的通用属性 - accesskey, style, class, title, tabindex, id, dir, spellcheck, hidden, contenteditable, contextmenu, draggable, dropzone

示例

1、accesskey - 用于定义快捷键element/_globalAttributes/accesskey.html

 
 
 
  1.  
  2.  
  3.  
  4.     accesskey 
  5.  
  6.  
  7.      
  8.     webabcd blog 
  9.     webabcd blog 
  10.  
  11.  

2、style - 用于定义样式element/_globalAttributes/style.html

 
 
 
  1.  
  2.  
  3.  
  4.     style 
  5.  
  6.  
  7.      
  8.     webabcd 
  9.  
  10.  

3、class - 指定需要应用的 css 类选择器element/_globalAttributes/class.html

 
 
 
  1.  
  2.  
  3.  
  4.     class 
  5.      
  6.  
  7.  
  8.      
  9.     webabcd 
  10.  
  11.  

4、title - 用于描述元素信息,相当于 ToolTipelement/_globalAttributes/title.html

 
 
 
  1.  
  2.  
  3.  
  4.     title 
  5.  
  6.  
  7.      
  8.     webabcd blog 
  9.      
  10.  
  11.  

#p#

5、tabindex - 用于定义 TAB 键的导航顺序(整型值)element/_globalAttributes/tabindex.html

 
 
 
  1.  
  2.  
  3.  
  4.     tabindex 
  5.  
  6.  
  7.      
  8.        
  9.      
  10.      
  11.      
  12.      
  13.      
  14.      
  15.  
  16.  

6、id - 用于定义元素的唯一标识,主要给 DOM 用element/_globalAttributes/id.html

 
 
 
  1.  
  2.  
  3.  
  4.     id 
  5.  
  6.  
  7.      
  8.     webabcd blog 
  9.  
  10.      
  11.         alert(document.getElementById('myId').innerHTML);  
  12.      
  13.  
  14.  

7、dir - 文本排列方向,可能的值有:auto|ltr|rtl(dir 是 direction 的缩写)element/_globalAttributes/dir.html

 
 
 
  1.  
  2.  
  3.  
  4.     dir 
  5.  
  6.  
  7.      
  8.     123 
  9.  
  10.  

8、spellcheck - 是否使用浏览器的拼写检查功能对元素内的内容做拼写检查element/_globalAttributes/spellcheck.html

 
 
 
  1.  
  2.  
  3.  
  4.     spellcheck 
  5.  
  6.  
  7.      
  8.      
  9. i am jack, i am webabcd, haha, good, hehe  
  10.      
  11.  
  12.  

#p#

9、hidden - 用于隐藏元素(不占位)element/_globalAttributes/hidden.html

 
 
 
  1.  
  2.  
  3.  
  4.     hidden 
  5.  
  6.  
  7.      
  8.          
  9.      
  10.      
  11.  
  12.  

10、contenteditable - 用于定义内容是否可编辑element/_globalAttributes/contenteditable.html

 
 
 
  1.  
  2.  
  3.  
  4.     contenteditable 
  5.  
  6.  
  7.      
  8.     我是可以编辑的,试试看

     
  9.  
  10.  

11、contextmenu - 指定上下文菜单的数据源element/_globalAttributes/contextmenu.html

 
 
 
  1.  
  2.  
  3.  
  4.     contextmenu 
  5.  
  6.  
  7.      
  8.      
  9.          
  10.          
  11.              
  12.              
  13.              
  14.                  
  15.                  
  16.              
  17.          
  18.      
  19.      
  20.      
  21.          
  22.             
  23.  
  24.                  
  25.                      
  26.                         New... 
  27.                      
  28.                         Open... 
  29.                      
  30.                         Save 
  31.                      
  32.                         Save as... 
  33.                  
  34.             
  35.  
  36.             
  37.  
  38.                  
  39.                      
  40.                         Copy 
  41.                      
  42.                         Cut 
  43.                      
  44.                         Paste 
  45.                  
  46.             
  47.  
  48.             
  49.  
  50.                  
  51.                     
  52. Help
  53.  
  54.                     
  55. About
  56.  
  57.                  
  58.             
  59.  
  60.          
  61.      
  62.  
  63.  

12、draggable - 元素是否可拖拽;dropzone - 拖放的目标元素(可承载被拖拽元素的元素)element/_globalAttributes/draggable_dropzone.html

 
 
 
  1.  
  2.  
  3.  
  4.     draggable dropzone 
  5.  
  6.  
  7.     关于 draggable 和 dropzone 的详细说明,参见 /other/drag_drop 
  8.  
  9.  

[源码下载]

原文链接:http://www.cnblogs.com/webabcd/archive/2012/02/02/2335318.html


当前文章:HTML5深入浅出教学篇之五
本文链接:http://gydahua.com/article/dhssdjg.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流