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 selected text input javascript

function disp() {
  var text = document.getElementById("text");
  var t = text.value.substr(text.selectionStart, text.selectionEnd - text.selectionStart);
  alert(t);
}
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 :: boucle foreach js 
Javascript :: convert js date to utc 
Javascript :: vue boolean 
Javascript :: one component to another component in vuejs trigger function 
Javascript :: dull a background image in react native 
Javascript :: document.queryselector picks first or last 
Javascript :: refresh ajax jquery 
Javascript :: module.exports multiple functions 
Javascript :: react native style variable 
Javascript :: react native map 
Javascript :: two sum js 
Javascript :: sanitize html in javascript 
Javascript :: accordion reatjs 
Javascript :: js object from array of keys 
Javascript :: HashRouter 
Javascript :: javascript Create Strings 
Javascript :: mometjs 
Javascript :: best reactjs course on udemy 
Javascript :: get min/max array 
Javascript :: Get specific elements from an object by using filter method 
Javascript :: selected value 
Javascript :: enable swipe using javascript 
Javascript :: ? operator in js 
Javascript :: react protected route 
Javascript :: json stringify number 
Javascript :: unwind mongodb 
Javascript :: js number to str 
Javascript :: js content editable 
Javascript :: how to create a object in javascript 
Javascript :: clone aJavaScript object 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =