So what I am reading is that when an element is added without specifying a class already, Also use addClass ()
For example,
.addClass ('myclass') using The more efficient I can add anything to the addId ('Married') to add the ID selectors, I / I>
.attr ('class',' myclass ') This is present or the most to add the ARR (ID) selector Good way
I think this ID is unique, the reason behind my question is that the addClass () is faster than attr ().
So my question is if there is a more efficient method to create an ID from atr ().
< / may be more than the attribute and Change the function of so many jQuery addClass () class attribute helps to add value. Similarly, the work toggleclass () and 'removeClass () `help in manipulating them. But the function attr () will only manipulate the attribute and change it directly. For example:
& lt; Div id = "person" & gt; No & lt; / Div & gt; and the following jQuery statement
$ ("# div"). AddClass ("tall"); // This will create a class attribute and add a long $ ("# div"). AddClass ("fat"); // It will add fat to the existing class and make "tall fat" $ ("# div"). Adclass ("gray"); // same .addClass () will just add the class name. If you only need one using the attr () then you have to do $ ("# div"). Attr ('class', 'tall'); $ ("# Div"). Ether ('square', 'tall fat'); $ ("# Div"). Ether ('class', 'tall fat brown'); Or, you can modify the attribute using
$ ("# div"). Attr ('class', function (i, className) {return classname + "brown";}); Where id has a value that needs to be modified or changed, so the function like addId () must be done correctly ('Id', 'idvalue').
No comments:
Post a Comment