Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get selection value javascript

var e = document.getElementById("ddlViewBy");
var strUser = e.value;
Comment

get element of selection javascript

function getSelectionBoundaryElement(isStart) {
    var range, sel, container;
    if (document.selection) {
        range = document.selection.createRange();
        range.collapse(isStart);
        return range.parentElement();
    } else {
        sel = window.getSelection();
        if (sel.getRangeAt) {
            if (sel.rangeCount > 0) {
                range = sel.getRangeAt(0);
            }
        } else {
            // Old WebKit
            range = document.createRange();
            range.setStart(sel.anchorNode, sel.anchorOffset);
            range.setEnd(sel.focusNode, sel.focusOffset);

            // Handle the case when the selection was selected backwards (from the end to the start in the document)
            if (range.collapsed !== sel.isCollapsed) {
                range.setStart(sel.focusNode, sel.focusOffset);
                range.setEnd(sel.anchorNode, sel.anchorOffset);
            }
       }

        if (range) {
           container = range[isStart ? "startContainer" : "endContainer"];

           // Check if the container is a text node and return its parent if so
           return container.nodeType === 3 ? container.parentNode : container;
        }   
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript execute function after async 
Javascript :: .includes meaning in javascript 
Javascript :: random color generator 
Javascript :: send params in nested screen 
Javascript :: Usage rate-limiter 
Javascript :: MaterialRippleLayout dependency 
Javascript :: delete request from the script to html 
Javascript :: multi key cookie js 
Javascript :: foreach in the elements with a data attibute jquery 
Javascript :: react classname 
Javascript :: router nodejs 
Javascript :: scroll js 
Javascript :: claim faucets 
Javascript :: vb net textbox regular expression 
Javascript :: ajaxsetup beforesend 
Javascript :: how to navigate to another page with settimeout reactjs 
Javascript :: jquery autocomplete search 
Javascript :: table to pdf javascript 
Javascript :: post request enabled in express js 
Javascript :: jsconfig.json code to support absolute import 
Javascript :: text animation css and js 
Javascript :: cy visit cypress 
Javascript :: how to add value with useref in react 
Javascript :: webpack dev srcipt 
Javascript :: react return multiple components 
Javascript :: .includes javascript 
Javascript :: webpack test js or jsx 
Javascript :: node js download image from url as buffer 
Javascript :: Get Input arrays 
Javascript :: using dot prototype with constructor in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =