Search
 
SCRIPT & CODE EXAMPLE
 

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());
}
Comment

Swap a select text with javascript

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<select id="se1">
  <option value="1">DOG</option>
  <option value="2">CAT</option>
  <option value="3">BIRD</option>
</select>
<button onclick="swap()">SWAP</button>
<select id="se2">
  <option value="4">DOG</option>
  <option value="5">CAT</option>
  <option value="6">BIRD</option>
</select>
Comment

PREVIOUS NEXT
Code Example
Javascript :: add a string regex in angular input 
Javascript :: image name validate using regex javascript 
Javascript :: how to check if element is in viewport javascript 
Javascript :: How to scan a folder for documents with javascript 
Javascript :: react-app-rewired test single file 
Javascript :: player.filter 
Javascript :: js set visibility 
Javascript :: return array javascript 
Javascript :: run javascript in flutter 
Javascript :: agrgar atributo con id jquey 
Javascript :: havascript The toExponential() Method 
Javascript :: dividing a number into digits javascript 
Javascript :: react native detect platform 
Javascript :: reactnaviataion change title 
Javascript :: if else react render in jsc 
Javascript :: React: readmore and read less 
Javascript :: node js gitignore 
Javascript :: Datatable shows No data available in table in angular 
Javascript :: twhat is a js promise 
Javascript :: angular keyframes % 
Javascript :: how to remove letters from an array javascript 
Javascript :: replaceAll vs replace vs split join 
Javascript :: register service worker 
Javascript :: Which condition will print hello? var a=2; var b=3; if(a___?___b){console.log(“Hello”);} 
Javascript :: package.json 
Javascript :: elasticsearch response format 
Javascript :: this keyword in javascript 
Javascript :: javascript to Postgress 
Javascript :: .tolowercase 
Javascript :: javascript wait to execute function on keyup 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =