Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get selected text js

// Get highlighted text this way:

window.getSelection().toString()
Comment

get the value or text from select element using javaScript

<select id="ddlViewBy">
  <option value="1">test1</option>
  <option value="2" selected="selected">test2</option>
  <option value="3">test3</option>
</select>
Running this code:

var e = document.getElementById("ddlViewBy");
var strUser = e.value;
Would make strUser be 2. If what you actually want is test2, then do this:

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].text;
Comment

get text from selected select javascript object

this.options[this.selectedIndex].text
Comment

javascript get selected text

const getSelectedText = () => window.getSelection().toString();

getSelectedText();
Comment

get text selection javascript

function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        text = document.selection.createRange().text;
    }
    return text;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript date today dd mm yyyy 
Javascript :: mm dd yyyy how to get date in this format in javascript 
Javascript :: apache angular routing 
Javascript :: tailwind css prefix 
Javascript :: javascript rectangle collision 
Javascript :: javascript reverse array without modifying 
Javascript :: jquery radio button checked event 
Javascript :: how to differentiate latitude and longitude from same value in different textbox 
Javascript :: discord.js channel regex 
Javascript :: angular run validation on other controls 
Javascript :: reactjs compile subdomine 
Javascript :: how to focus icon of active screen react native 
Javascript :: setattribute disabled javascript 
Javascript :: javascript delete row by id 
Javascript :: js is prime 
Javascript :: laravel javascript array from blade 
Javascript :: how to put background image in angular 11 
Javascript :: Javascript Remove Element By Id Code Example 
Javascript :: js pgrah 
Javascript :: nodejs sharp resize to max width or height 
Javascript :: default error handler express 
Javascript :: electron js Not allowed to load local resource 
Javascript :: Ckeditor get content html 
Javascript :: fill all field of object in js 
Javascript :: next js update 
Javascript :: js find node number in div 
Javascript :: get current url javascript 
Javascript :: javascript get object from array where property equals 
Javascript :: add readonly attribute jquery 
Javascript :: javascript auto save input 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =