js获取选中文本

                function funGetSelectTxt() {
			var txt = "";
			if(document.selection) {
				txt = document.selection.createRange().text;	// IE
			} else {
				txt = document.getSelection(); //w3c
			}
			return txt.toString();
		};

		$('.content').mouseup(function(){
			var text = funGetSelectTxt();
			console.log(text)

		})

  

posted on 2016-07-01 15:01  什么嘉  阅读(142)  评论(0编辑  收藏  举报

导航