怎样用js取得/设置表格的所有属性?
来源:互联网 发布:linux安装配置apache 编辑:程序博客网 时间:2024/06/11 04:55
我看到有人用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'); //去掉某个属性
- 怎样用js取得/设置表格的所有属性?
- JS设置所有表格斑马显示
- js操作表格的属性
- 怎样用JS获取DataGrid中CheckBox是否选中,并且取得该行的DataGrid数据?
- 怎样用JS获取DataGrid中CheckBox是否选中,并且取得该行的DataGrid数据?
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- JS如何取得当前对象的属性
- C#如何取得类中所有静态属性的值
- 怎样用JS给,option添加“选中”属性
- js创建表格、创建input、判断浏览器类型、设置新创建的input的name属性
- JS取得URL所有参数
- 用JS取得页面上所有元素的值
- jQuery中动态设置表格的属性
- C# winform 设置Excel表格的属性
- JS动态创建表格,动态设置属性,动态添加事件
- JS动态创建表格,动态设置属性,动态添加事件
- JS动态创建表格,动态设置属性,动态添加事件
- JavaBean设置与取得属性
- asp.net1.1中DataList如何实现分页
- 在远程lookup一个EJB后,要调用PortableRemoteObject.narrow去强制转换
- 使用Servicemix(ESB)发布一个外部的WebService
- sql2k 求救
- 计算日期间隔
- 怎样用js取得/设置表格的所有属性?
- WEB页面在输出JS的代码后变形的问题解决方法
- OllyDBG 入门系列(五)-消息断点及 RUN 跟踪
- Spring之BeanFactory与ApplicationConText区别
- OllyDBG 入门系列(七)-汇编功能
- Linux on-the-fly kernel patching without LKM
- 反汇编解读
- C#中的委托和事件(续)
- windows mobile上调用摄像头接口