Select| selected
To get the value of the partial check (selected) in input (for IE and Firefox), this is a good example to share.
<textarea id="code"><script language= "javascript" >var agt=navigator.useragent.tolowercase (); var ie = (Agt.indexof ("MSIE")!=- 1) && (Agt.indexof ("opera") = = 1) && (Agt.indexof ("omniweb") = = 1); function A () {var myarea = Document.g Etelementbyid ("s"); var selection;if (!ie) {if (myarea.selectionstart!= undefined) {selection = MyArea.value.substr ( Myarea.selectionstart, Myarea.selectionend-myarea.selectionstart);} Else{if (window.getselection) {selection = Window.getselection ();} else if (document.getselection) {selection = Document.getselection ();} else if (document.selection) {selection = Document.selection.createRange (). text;}} Alert (selection)}</script><input type= "text" value= "Testtest" id= "S" name= "s"/></textarea>
Run code Copy Code Save Code Collect this page