`

select-text-in-javascript

阅读更多
	
function selectText(element) {
		if (document.body.createTextRange) { // ms
			var range = document.body.createTextRange();
			range.moveToElementText(element);
			range.select();
		} else if (window.getSelection) { // moz, opera, webkit
			var selection = window.getSelection();
			var range = document.createRange();
			range.selectNodeContents(element);
			selection.removeAllRanges();
			selection.addRange(range);
		}
	}
分享到:
评论

相关推荐

    selectAll Text in Javascript.zip

    JavaScript

    JavaScript 圣经第5版-Javascript编程宝典--黄金版 .rar

    The book includes all the great content included in the JavaScript Bible, 4th Edition, an international bestseller, plus over 400 pages of new material. The Gold Bible features essential new ...

    Image-Text-Selector:使用鼠标光标从网页上的图像中选择文本

    图像文本选择器 笔记: 仅在本地托管索引文件后才运行index.html,否则将不会获取XML文件。 如果使用VS CODE,则可以使用名为“ Live Server”的扩展名。 或者在这里查看演示

    JavaScript语言参考手册

    for...in function if...else import labeled return switch var while with 第四章 核心 这一章包含了 JavaScript 的核心对象 Array,Boolean,Date,Function,Math,Number,Object 和 String。这些对象同时在...

    JavaScript中文参考手册

    for...in function if...else import labeled return switch var while with 第四章 核心 这一章包含了 JavaScript 的核心对象 Array,Boolean,Date,Function,Math,Number,Object 和 String。这些...

    JavaScript权威指南

    JavaScript in Other Contexts Section 1.5. Client-Side JavaScript: Executable Content in Web Pages Section 1.6. Client-Side JavaScript Features Section 1.7. JavaScript Security Section 1.8. ...

    Jquery 获取表单text,areatext,radio,checkbox,select值的代码

    获取select被选中项的文本 var item = $(“select[@name=items] option[@selected]”).text(); select下拉框的第二个元素为当前选中值 $(‘#select_id’)[0].selectedIndex = 1; radio单选组的第二个元素为当前选中...

    eclipse-testng 离线包下载

    <xsl:output name="text" method="text"/> <xsl:output name="html" method="html" indent="yes" omit-xml- declaration="yes"/> <xsl:output name="xhtml" method="xhtml" indent="yes" omit-xml-...

    asp连接数据库代码实例

    转到:<select name=\"select\" onChange=\'javascript:window.open(this.options[this.selectedIndex].value,\"_top\")\'> <%for p=1 to rs.pagecount%> <option value=\"?page=<%=p%>\" ...

    Selenium.WebDriver.Recipes.in.Csharp.2nd.Edition.1484217

    How to locate web elements and test functions for hyperlinks, buttons, TextFields and TextAreas, radio buttons, CheckBoxes, and more How to use Selenium WebDriver for select lists, navigation, ...

    UE(官方下载)

    The selected text compare allows you to select portions of text between 2 files and execute a compare on ONLY the se Using the SSH/telnet console A tutorial for UltraEdit/UEStudio's SSH/telent ...

    ExtAspNet v2.2.1 (2009-4-1) 值得一看

    -增加示例(data/tree_select_run.aspx),如何选中当前节点的所有子节点(feedback:wjl_wjl520)。 +TreeNode的属性NodeId被重命名为NodeID,这是ExtAspNet中的一个命名约定。 -同时更名的还有GridColumn的...

    sciter-sdk-4.0.3.5348

    cr/lf handling in plaintext editing. Fix of click on <label> when bound input is disabled. [tooltips] – better tooltips handling – now tooltip gets removed only when mouse leaves tooltip’s owner ...

    网上图书销售数据库+ASP

    '-------------------------------------------------------------------- ' Microsoft ADO ' ...' ' ' ' ADO constants include file for VBScript ' '------------------------------------------------------------...

    jukebox:点唱机形式的音频播放器,它使用es6-javascript,html5-audio,oop创建,并包括文本搜索框

    自动点唱机欢迎来到沟槽我JavaScript Jukebox应该: 页面加载时在页面上显示至少一首歌曲使用户无需使用“内置”播放按钮即可播放该歌曲。 这可以通过其他按钮,单击或将鼠标悬停在页面或我们选择的任何其他设备上的...

    JavaScript Table行定位效果

    <style type="text/css"> .t{width:100px; border-collapse:collapse;} .t td{border:5px solid #999;} <td>1 <td>1 <td>1 <td>1 <td>1 <td>1 <td>1 <td>1 ...

    107个常用javascript语句

    state_select.options[i].text = state_array[(i-1)*2+1] ; } 1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4.一个浏览器窗口中的DOM顺序是:window->...

    SWFUpload jwplayer

    •The ability to select multiple files in the file browser dialog. •AJAX-style uploading without a page refresh. •Upload progress events. •Namespaced classes compatible with other JavaScript ...

    七 种 JS分 页效果

    Supported in Internet Explorer, Mozilla Firefox */ function showPages(name) { //初始化属性 this.name = name; //对象名称 this.page = 1; //当前页数 this.pageCount = 1; //总页数 this.argName = 'page...

    fso浏览54646465465464564

    For Each oDrive In oFso.Drives Response.Write "(this.value);""" If Islight Then Response.Write " bgcolor='#EEEEEE'" Response.Write ">" Response.Write "<td>"&oDrive.DriveLetter&"</td>" ...

Global site tag (gtag.js) - Google Analytics