全选中,控制部分TD内容不被选中

wwg19848 2012-04-24 03:35:39
<style type="text/css"> 
.aa{gn:expression(this.onselectstart=function(){return false;})}
</style>

<table>
<tr>
<td id= "td1" class="aa"> abc </td>
</tr>
</table>
<table>
<tr>
<td onselectstart="return true"> world </td>
</tr>
</table>
<script language= "javascript">
function enableSelect(bAllowed)
{
var td = document.getElementById( "td1");
td.onselectstart=function(){event.returnValue=bAllowed};
}
function isshow(e) {

}
</script>


现状:当双击abc,td不能被选中,全选,会被选中。
目的:全选时候,abc也可以不被选中
...全文
132 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwg19848 2012-04-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

<script language= "javascript">
var lastSelection=null;
function selects(element){
var e,r,c;
if(element==null)
{
e=event.srcElement;
}else{
e=element;
}
if(e.tagName=="TD")
{
c=findce……
[/Quote]
感谢!
能把全部代码贴出来么?
我想补充一下,控制abc不被选中,而world可以被选中
missgd152 2012-04-24
  • 打赏
  • 举报
回复
<script language= "javascript">
var lastSelection=null;
function selects(element){
var e,r,c;
if(element==null)
{
e=event.srcElement;
}else{
e=element;
}
if(e.tagName=="TD")
{
c=findcell(e);
if(c!=null){
if(lastSelection!=null){
deselectroworcell(window.lastSelection);
}
selectroworcell(c);
lastSelection=c;
}
}
window.event.cancelBubble=true;
}
table1.onclick=selects;
function findcell(e){
if(e.tagName=="TD"){
return e;
}else if(e.tagName=="BODY"){
return null;
}else{
return findcell(e.parentElement);
}
}
function selectroworcell(r){
r.runtimeStyle.backgroundColor="darkblue";
r.runtimeStyle.color="white";
}
function deselectroworcell(r){
r.runtimeStyle.backgroundColor="";
r.runtimeStyle.color="";
}
</script> try!!!

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧