I am looking for a way to swap to option values between them.
I made a simple fiddle which would swap inputs but when I change it to select options it doesn’t seem to work.
I’m using the method of Address. Eg:
var prevAddress = $(this).parent().prev('.forms').find('.first option');
var nextAddress = $(this).parent().next('.forms').find('.second option');
var tmp = prevAddress.val();
prevAddress.val(nextAddress.val());
nextAddress.val(tmp);
Here’s the fiddle: http://jsfiddle.net/rfe8K/
Thanks alot
<select>elements don’t work that way. The.val()of a<select>element is the current value but you can’t set a<select>to a value that it doesn’t contain, you have to make sure that the<select>has an<option>child that matches the value you want to set; just calling.val('pancakes')doesn’t add an<option value="pancakes">to the<select>.What you need to do is move the contained
<option>element from the first<select>to the second and vice versa. Something more like this:And an updated fiddle: http://jsfiddle.net/ambiguous/VrUmQ/1/