怎样用js取得/设置表格的所有属性?
2012-03-09 00:00
411 查看
我看到有人用setAttrib()函数,具体怎么用?
怎么取得/设置所选表格的所有属性
setAttribute版本:DOM1 返回值:无
语法:
object . setAttribute ( sName , vValue , iFlags )
参数:
sName : 必选项。字符串(String)。指定属性的名称。
vValue : 必选项。要赋给属性的值。可以是任何需要的变量类型。
iFlags : 可选项。整数值(Integer)。0 | 1 0 : 当属性被设置的时候,对象任何已有的同名属性设置都会被覆盖,而不会考虑它们的大小写。
1 : 默认值。执行严格考虑字母大小写的属性设置。假如此方法的 iFlags 参数设置为 1 ,则执行 iFlags 参数设置为 0 的 getAttribute 方法时,满足 sAttrName 指定的特性名称不一定能被找到。
返回值:
无
说明:
设置指定的属性值。
假如指定的属性尚不存在,则此方法会为对象添加属性并赋值。
请务必小心拼写属性名称。假如你设置 iFlags 参数为 1 ,但是 sName 参数的字母大小写不符合您所期望赋值的属性名称,则此方法的执行结果会是新的属性被建立并赋值。
假如对象有多个名字一样但字母大小写不同的属性,并且 iFlags 参数被设为 0 ,那么只有其中第一个被建立的那一个会被此方法获取。而其他的则会被忽略。
当使用此方法获取 CLASS 属性的值时,需要将 sName 参数指定为 className 。这是 CLASS 属性所对应的 DHTML 特性。
E文:
setAttribute
--------------------------------------------------------------------------------
Description
Sets the value of the given attribute. If the attribute is not already present, the method adds the attribute to the element and sets the value.
Syntax
object.setAttribute(attrName , value [, caseSensitive])
Parameter Description
attrName String specifying the name of the attribute.
value String, number, or Boolean value to assign to the attribute.
caseSensitive Optional. Boolean value specifying whether to use a case-sensitive search to locate the attribute. If TRUE, the uppercase and lowercase letters in attrName must match exactly those in the attribute name. By default, this parameter is TRUE.
Return Value
No return value.
Remarks
Be careful when spelling attribute names. If caseSensitive is TRUE and attrName does not have the same uppercase and lowercase letters as the attribute, this method creates a new attribute.
If two or more attributes have the same name (differing only in uppercase and lowercase letters) and caseSensitive is FALSE, this method assigns a value only to the first attribute (the first to be created with this name). All other attributes of the same name are ignored.
Applies To
A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XMP, style
怎样取得属性,用getAttrib()?
div.style.getAttribute("color");
div.style.setAttribute('color', '#FF0000');
div.style.removeAttribute('color'); //去掉某个属性
$(document).ready(function(){dp.SyntaxHighlighter.HighlightAll('code');});
原文链接:
http://blog.csdn.net/vince6799/article/details/2881023
怎么取得/设置所选表格的所有属性
setAttribute版本:DOM1 返回值:无
语法:
object . setAttribute ( sName , vValue , iFlags )
参数:
sName : 必选项。字符串(String)。指定属性的名称。
vValue : 必选项。要赋给属性的值。可以是任何需要的变量类型。
iFlags : 可选项。整数值(Integer)。0 | 1 0 : 当属性被设置的时候,对象任何已有的同名属性设置都会被覆盖,而不会考虑它们的大小写。
1 : 默认值。执行严格考虑字母大小写的属性设置。假如此方法的 iFlags 参数设置为 1 ,则执行 iFlags 参数设置为 0 的 getAttribute 方法时,满足 sAttrName 指定的特性名称不一定能被找到。
返回值:
无
说明:
设置指定的属性值。
假如指定的属性尚不存在,则此方法会为对象添加属性并赋值。
请务必小心拼写属性名称。假如你设置 iFlags 参数为 1 ,但是 sName 参数的字母大小写不符合您所期望赋值的属性名称,则此方法的执行结果会是新的属性被建立并赋值。
假如对象有多个名字一样但字母大小写不同的属性,并且 iFlags 参数被设为 0 ,那么只有其中第一个被建立的那一个会被此方法获取。而其他的则会被忽略。
当使用此方法获取 CLASS 属性的值时,需要将 sName 参数指定为 className 。这是 CLASS 属性所对应的 DHTML 特性。
E文:
setAttribute
--------------------------------------------------------------------------------
Description
Sets the value of the given attribute. If the attribute is not already present, the method adds the attribute to the element and sets the value.
Syntax
object.setAttribute(attrName , value [, caseSensitive])
Parameter Description
attrName String specifying the name of the attribute.
value String, number, or Boolean value to assign to the attribute.
caseSensitive Optional. Boolean value specifying whether to use a case-sensitive search to locate the attribute. If TRUE, the uppercase and lowercase letters in attrName must match exactly those in the attribute name. By default, this parameter is TRUE.
Return Value
No return value.
Remarks
Be careful when spelling attribute names. If caseSensitive is TRUE and attrName does not have the same uppercase and lowercase letters as the attribute, this method creates a new attribute.
If two or more attributes have the same name (differing only in uppercase and lowercase letters) and caseSensitive is FALSE, this method assigns a value only to the first attribute (the first to be created with this name). All other attributes of the same name are ignored.
Applies To
A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XMP, style
怎样取得属性,用getAttrib()?
div.style.getAttribute("color");
div.style.setAttribute('color', '#FF0000');
div.style.removeAttribute('color'); //去掉某个属性
$(document).ready(function(){dp.SyntaxHighlighter.HighlightAll('code');});
原文链接:
http://blog.csdn.net/vince6799/article/details/2881023
相关文章推荐
- 怎样用js取得/设置表格的所有属性?
- js创建表格、创建input、判断浏览器类型、设置新创建的input的name属性
- JS动态创建表格,动态设置属性,动态添加事件
- JS设置所有表格斑马显示
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- masterpage中服务器端控件命名规则和如何用控件名取得document中的对象,用js动态设置控件事件和属性
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- JS动态创建表格,动态设置属性,动态添加事件
- JS动态创建表格,动态设置属性,动态添加事件
- js(JQuery) 设置servercontrol(服务器控件)的text属性
- C# .NET 遍历一个Web页面中所有的TextBox控件 并设置读写属性
- js 49 取得display属性
- js、jquery获取、设置元素属性与样式
- 网页布局自适应和JS设置IMG属性
- 用JS 设置 控件 属性
- 遍历js的obj中所有属性得key
- 浅析js设置控件的readonly与enabled属性问题
- cocos js 怎样设置一个按钮(MenuItemSprite)为不可点击状态?
- JS设置控件属性