jQuery中的addID? [英] addID in jQuery?

查看:122
本文介绍了jQuery中的addID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有像添加类一样的方法来添加ID-addClass()?

Is there any method available to add IDs like there is for adding a class - addClass()?

推荐答案

ID是一个属性,您可以使用 attr 函数:

ID is an attribute, you can set it with the attr function:

$(element).attr('id', 'newID');

我不确定您对添加ID 的含义,因为一个元素只能有一个标识符,并且该标识符必须是唯一的.

I'm not sure what you mean about adding IDs since an element can only have one identifier and this identifier must be unique.

这篇关于jQuery中的addID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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