日期:2014-05-20  浏览次数:20455 次

怎么让<span>一获得焦点就把里面的内容选中?
RTRT

------解决方案--------------------
<html>
<head>
<title> 这个是我改的还没测试,呵呵 </title>
<script type= "text/javascript ">
//复制代码
function doCopy() {
if (!document.all){
alert( "此功能只能在IE上有效 ");
return ;
}
var source = event.srcElement;
if(source.tagName == "span ")
{
textRange = source.innerHTML;
textRange.execCommand( "Copy ");
}
}
</script>
<head>
<body>
<span onclick= "doCopy();event.cancelBubble=true; ">
That quick brown fox jumps over the lazy dog.
</span>
</body>
</html>