我有以下代码。
$(document).ready(function(){
$('#listing img')
.attr('width', 250)
.removeAttr('height').removeAttr('align').removeAttr('style')
.wrap('<p />');
});
有没有更有效的方法来删除多个属性?
我有以下代码。
$(document).ready(function(){
$('#listing img')
.attr('width', 250)
.removeAttr('height').removeAttr('align').removeAttr('style')
.wrap('<p />');
});
有没有更有效的方法来删除多个属性?
Answers:
是的,您可以通过以下方式将其删除:
$('#listing img').removeAttr('height align style');
您还可以如下添加这些属性:
$('#listing img').attr({ height: "20", align: left }).css({ color: red, text-align: center });