.uniqueId()


.uniqueId()Returns: jQuery

Description: Generate and apply a unique id for the set of matched elements.

  • version added: 1.9.uniqueId()

    • This method does not accept any arguments.

Many widgets need to generate unique ids for elements. .uniqueId() will check if the element has an id, and if not, it will generate one and set it on the element. It is safe to call .uniqueId() on an element without checking if it already has an id. If/when the widget needs to clean up after itself, the .removeUniqueId() method will remove the id from the element if it was added by .uniqueId() and leave the id alone if it was not. .removeUniqueId() is able to be smart about this because the generated ids have a prefix of "ui-id-".