使用jQuery的removeAttr删除多个属性 [英] Remove multiple attributes with jQuery's removeAttr

查看:898
本文介绍了使用jQuery的removeAttr删除多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码.

$(document).ready(function(){
 $('#listing img')
 .attr('width', 250)
 .removeAttr('height').removeAttr('align').removeAttr('style')
 .wrap('<p />');
});

是否有一种更有效的删除多个属性的方法?

Is there a more efficient way of removing multiple attributes?

推荐答案

是:

.removeAttr('height align style')

来自文档:

从1.7版开始,它可以是一个用空格分隔的属性列表.

as of version 1.7, it can be a space-separated list of attributes.

这篇关于使用jQuery的removeAttr删除多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆