如何使用jQuery从一个div中删除一个id属性? [英] How to remove an id attribute from a div using jQuery?

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

问题描述

我想从此图片中移除id属性:

 < img width =270class =thumb id =thumbheight =270src =img / 1_1.jpg/> 

我试过这样做:

  $( 'IMG#拇指')RemoveAttr( '编号', '无')。 

但它不会删除ID!



编辑:

  $('img#thumb')。attr('src',response); 
$('img#thumb')。attr('id','nonthumb');

这个deosnt加载图片,或者在这个例子中是src!但是,当我删除id属性,它工作正常

解决方案

大写是错误的,你有一个额外的参数。 p>

改为:

  $('img#thumb')。 removeAttr( 'ID'); 

为了将来的参考,没有任何以大写字母开头的jQuery方法。它们都采用与此相同的形式,以小写字母开头,每个加入的单词的第一个字母都是大写。


I want to remove the id attribute from this image:

<img width="270" class="thumb" id="thumb" height="270" src="img/1_1.jpg" />

I tried doing this:

$('img#thumb').RemoveAttr('id','none');

But it is not removing the ID!

EDIT:

$('img#thumb').attr('src', response);
$('img#thumb').attr('id', 'nonthumb');

This deosnt load the picture, or in this case the src! But when I remove the id attribute, it works fine

解决方案

The capitalization is wrong, and you have an extra argument.

Do this instead:

$('img#thumb').removeAttr('id');

For future reference, there aren't any jQuery methods that begin with a capital letter. They all take the same form as this one, starting with a lower case, and the first letter of each joined "word" is upper case.

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

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