You have a drop-down box for colors and want to add new colors to it, as well as remove options from it.
To add a new option to the drop-down box, use the .appendTo() method:
I use the .attr() and .text() methods to populate the <option>element:
However, the same line could be rewritten so that the <option>element is built in onestep, without using the methods:
Concatenating all the <option>data like that would be a fraction of a millisecond faster,but not in any way noticeable by a human. I prefer using the .attr() and .text()methods to populate the <option>element because I think that it is more readable and easier to debug and maintain. With the performance issue being negligible, using one approach or the other is the developer’s preference.
J Query Related Interview Questions
|HTML 4 Interview Questions||HTML Interview Questions|
|HTML 5 Interview Questions||Zend Interview Questions|
|JqueryUI Interview Questions||Dynamic HTML Interview Questions|
|XQuery Interview Questions||jQuery Mobile Interview Questions|
J Query Related Practice Tests
|HTML 4 Practice Tests||HTML Practice Tests|
|HTML 5 Practice Tests||Zend Practice Tests|
|PHP and Jquery Practice Tests||J Query Practice Tests|
|CodeIgniter Practice Tests||Dynamic HTML Practice Tests|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.