Jquery下attr和removeAttr的使用方法
下面我们来具体看一下attr的用法: 一、attr(name):取得第一个匹配元素的属性值。通过这个方法可以方便地从第一个匹配元素中获取一个属性的值。如果元素没有相应属性,则返回 undefined 。其中name为string.下面我用一个img元素演示一下这种用法: 实现代码如下: //html
下面我们来具体看一下attr的用法: 一、attr(name):取得第一个匹配元素的属性值。通过这个方法可以方便地从第一个匹配元素中获取一个属性的值。如果元素没有相应属性,则返回 undefined 。其中name为string.下面我用一个img元素演示一下这种用法: 实现代码如下: //html
看下面code: 实现代码如下: TestPage $(document).ready(function() { $("#btn1").unbind('click').removeAttr('onclick').click(function() { alert('The method has
操作属性 jQuery提供.attr()方法改变属性值,.removeAttr()方法删除属性 实现代码如下: $(document).ready(function(){ $('div.character a').each(function(index){ $(this).attr({ 'rel':
在IE7中, 使用jQuery 显示:$("#a").attr("style",""); 隐藏:$("#a").attr("style","display:none"); 但是显示这个方法在IE8中不行 IE8 显示:$("#a").removeAttr("style"); 隐藏:$("#a").a