Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Swap a select text with javascript

var sel1 = $("#se1");
var sel2 = $("#se2");
function swap() {
  let selection1 = sel1[0].selectedIndex;    // Store the first list's selection
  sel1[0].selectedIndex = sel2[0].selectedIndex;
  sel2[0].selectedIndex = selection1;
  
  // Test
  console.log(sel1.val(), sel2.val());
}
 
PREVIOUS NEXT
Tagged: #Swap #select #text #javascript
ADD COMMENT
Topic
Name
2+4 =