Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you copy one dropdown's options to another dropdown using jquery [duplicate]

Tags:

html

jquery

Possible Duplicate:
Copy option list from dropdownlist. JQuery

In Jquery how do you copy options of one dropdown to another dropdown?

like image 613
Ravi Bhartiya Avatar asked Mar 18 '26 21:03

Ravi Bhartiya


1 Answers

You can do something like this:

$('#destination').html($('#source').html());

or

$('#destination').append($('#source').html());

$('something').html() grabs the html from an element.

$('something').html('something') replaces the current html from the element with the new html.

$('something').append('something') puts the new html at the end of the old html in the element. (this does not replace).

like image 146
Razor Storm Avatar answered Mar 20 '26 18:03

Razor Storm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!