Answers for "select option selected text javascript"

1

get text of selected option js

var sel = document.getElementById("box1");
var text= sel.options[sel.selectedIndex].text;
Posted by: Guest on June-22-2021
2

select text with javascript

// highlight text in an input element
element.select();

// highlight a portion of an element
// element.setSelectionRange(start, end, ?direction)
// start, end - start and end indices of the new selection
// direction (optional) - "forward", "backward", or "none" (default)
element.setSelectionRange(3, 5);
Posted by: Guest on May-30-2021

Code answers related to "select option selected text javascript"

Browse Popular Code Answers by Language