Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign custom property to jQuery object?

I need to assign a custom property to a jQuery object. Here is the object:

var object = $("<div id='item'></div>");

I need object to have a custom data member. How can I add this?

like image 577
Nathan Osman Avatar asked Apr 22 '10 22:04

Nathan Osman


People also ask

How to set style property in jQuery?

Set a Single CSS Property and Value The css() method can take a property name and value as separate parameters for setting a single CSS property for the elements. The basic syntax can be given with: $(selector). css("propertyName", "value");

How to use prop in jQuery?

The prop() method sets or returns properties and values of the selected elements. When this method is used to return the property value, it returns the value of the FIRST matched element. When this method is used to set property values, it sets one or more property/value pairs for the set of matched elements.


1 Answers

.data()

like image 80
Matt Avatar answered Sep 27 '22 23:09

Matt