JavaScript的setAttribute兼容性问题解决方法
var asubmit = document.getElementById("submit");
<span style="white-space:pre"> </span>asubmit.setAttribute("onclick","alert('请检查手机号码');"); //在火狐中有效,而在ie中无效
<span style="white-space:pre"> asubmit.setAttribute("onclick","javascript:document.buyform.submit();");</span> //在ie中有效,火狐也有效
相关推荐
-
javascript中attribute和property的区别详解
DOM元素的attribute和property很容易混倄在一起,分不清楚,两者是不同的东西,但是两者又联系紧密.很多新手朋友,也包括以前的我,经常会搞不清楚. attribute翻译成中文术语为"特性",property翻译成中文术语为"属性",从中文的字面意思来看,确实是有点区别了,先来说说attribute. attribute是一个特性节点,每个DOM元素都有一个对应的attributes属性来存放所有的attribute节点,attributes是一个类数
-
javascript中setAttribute兼容性用法分析
本文实例分析了javascript中setAttribute兼容性用法.分享给大家供大家参考,具体如下: 1:常规属性建议使用 node.XXXX. 2:自定义属性建议使用node.getAttribute("XXXX"). 3:当获取的目标是JS里的关键字时建议使用node.getAttribute("XXX"),如label中的for. 4:当获取的目标是保留字,如:class,请使用className代替. setAttribute(string name,
-
javascript 对象属性property与元素属性attribute的浏览器支持
var div = document.getElementById('myId'); div.userProperty = 'test2'; alert(div.attributes.length); // IE6/7/8 -> 4 , [id,class,userAttribute,userProperty] // IE9/FF -> 3, [id,class,userAttribute] alert(div.userAttribute); // IE6/7/8 -> 'test1'
-
js中的getAttribute方法使用示例
getAttribute()方法 至此,我们已经向大家介绍了两种检索特定元素节点的办法:一种是使用getElementById()方法,另一种是使用getElementsByTagName()方法.在找到那个元素后,我们就可以利用getAttribute()方法把它的各种属性的值查询出来. getAttribute()方法是一个函数.它只有一个参数--你打算查询的属性的名字: object.getAttribute(attribute) 不过,getAttribute()方法不能通过docume
-
javascript中setAttribute()函数使用方法及兼容性
setAttribute()函数可以设置对象的属性,如果不存在此属性,则会创建此属性. 语法结构: el.setAttribute(name,value) 参数列表: 参数 描述 name 必需.规定要设置的属性名. value 必需.规定要设置的属性值. 代码实例: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <script type="text/javas
-
JS getAttribute和setAttribute(取得和设置属性)的使用介绍
getAttribute:取得属性:setAttribute:设置属性: 复制代码 代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content=&q
-
JavaScript中的property和attribute介绍
首先看看这两个单词的英文释义(来自有道词典).先是property: 复制代码 代码如下: property ['prɔpəti] n. 性质,性能:财产:所有权 英英释义: any area set aside for a particular purpose "the president was concerned about the property across from the White House" 同义词:place something owned; any tangi
-
js setattribute批量设置css样式
firefox等可以使用 var dom=document.getElementById("name"); dom.setAttribute("style","width:10px;height:10px;border:solid 1px red;") ; IE中则必须使用style.cssText var dom=document.getElementById("name"); dom1.style.cssText = &q
-
JavaScript中setAttribute用法介绍
setAttribute(string name, string value):增加一个指定名称和值的新属性,或者把一个现有的属性设定为指定的值.1.样式问题setAttribute("class", value)中class是指改变"class"这个属性,所以要带引号.vName代表对样式赋值.例如: 复制代码 代码如下: var input = document.createElement("input");input.setAttribut
-
JS Attribute属性操作详解
Attribute是属性的意思,文章仅对部分兼容IE和FF的Attribute相关的介绍. attributes:获取一个属性作为对象 getAttribute:获取某一个属性的值 setAttribute:建立一个属性,并同时给属性捆绑一个值 createAttribute:仅建立一个属性 removeAttribute:删除一个属性 getAttributeNode:获取一个节点作为对象 setAttributeNode:建立一个节点 removeAttributeNode:删除一个节点 a
-
javascript setAttribute, getAttribute 在不同浏览器上的不同表现
测试环境(客户端浏览器 ) IE6,IE7, IE8兼容模式, IE8 Firefox 3.6.8, google chrome 5.0.375.125 先来说明两个函数的标准定义. elementNode.setAttribute(name,value) name 必需.规定要设置的属性名. value 必需.规定要设置的属性值. 该方法把指定的属性设置为指定的值.如果不存在具有指定名称的属性,该方法将创建一个新属性. elementNode.getAttribute(name) name 必
随机推荐
- JavaScript实现时间倒计时跳转(推荐)
- html的基本使用(HTML标签解释)
- 高性能WEB开发 web性能测试工具推荐
- hta实现的二进制文件转换为文本
- 教你设计大型Oracle数据库
- JQuery学习笔记 nt-child的使用
- JSON扫盲帖 JSON.as类教程
- SSH框架网上商城项目第10战之搭建商品类基本模块
- 浅析python 中__name__ = '__main__' 的作用
- JavaScript动态改变HTML页面元素例如添加或删除
- smarty实现PHP静态化的两种方法分享
- linux Shell入门:掌握Linux,OS X,Unix的Shell环境
- 一款域名监控小工具 Domain(IP)Watcher 实现代码
- asp.net 使用SqlBulkCopy极速插入数据到 SQL Server
- 用批处理实现Auto病毒专杀工具的代码
- C#实现流程图设计器
- 浅谈js 闭包引起的内存泄露问题
- android为ListView每个Item上面的按钮添加事件
- hibernate 中 fetch=FetchType.LAZY 懒加载失败处理方法
- php生成年月日下载列表的方法