Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery UI API – .uniqueId()

jQuery UI API - .uniqueId()

Category

Methods | UI Core

Usage

**Description:** Generates and applies a unique id to the set of matched elements.

Returns:jQuery

**Version added:** 1.9

.uniqueId()

This method accepts no arguments.

Many widgets need elements to generate unique ids..uniqueId() checks whether the element has an id; if not, it generates one and sets it as the element's id. It is safe to call .uniqueId() without first checking whether the element has an id. When a widget needs to be cleaned up after use, if the id was added by .uniqueId() , the.removeUniqueId() method will remove the id from the element; if the id was not added by .uniqueId() , there is no effect..removeUniqueId() The reason ids can be distinguished is that .uniqueId() generated ids have the prefix "ui-id-"。