请高手来帮帮,锚链接定位到TAB菜单里面的内容,但是该块本来是隐藏的 如何定位后显示出隐藏的块并让光标聚焦到内容里面啊! 本帖最后由 sxfd32 于 2010-11-26 13:52:47 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主什么意思呢?div 是获取不到焦点的!表单元素和 a 标签才能获得焦点 这个可以,但是聚焦的话就像1楼说的不能聚焦到DIV上的function theforever(){document.getElementById("con_one_2").style.display = "block";document.getElementById("con_one_1").style.display = "none";document.getElementById("sss").focus();document.getElementById('sss').parentNode.style.backgroundColor='#E4F2FD'; } 我前面不是做好了么,除了聚焦都可以了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><style type="text/css">#lib_Tab1{ margin:0px; padding:0px; height: 77px; width: 250px;}.lib_Contentbox{ text-align:left; width: 200px; float: left; height: 50px; border: thin solid #00CC33;}.lib_Menubox { height:20px; line-height:20px; width: 200px;}.lib_Menubox li{ float:left; display:block; cursor:pointer; width:60px; font-weight:bold; height:20px; line-height:20px; font-size: 10pt; background-color: #6699CC;}.lib_Menubox ul{ padding:0px; list-style:none; left:-5px; height:20px; text-align:center; z-index: 99; margin: 0px;} .lib_Menubox li.hover{ padding:0px; background:#fff; width:60px; color:#739242; height:20px; line-height:20px; border: 1px solid #95C9E1; position: relative;}.ss{ height: 40px; width: 100px; float: left; margin-left: 10px; border: thin solid #009933;} .a5{ height: 30px; width: 50px; border: thin solid #000000; top: 100px; position: relative;}--></style><body><div id="lib_Tab1"><div class="lib_Menubox"><ul> <li id="one1" onclick="setTab('one',1,2)" class="hover">新闻1</li> <li id="one2" onclick="setTab('one',2,2)" >新闻2</li></ul></div><div class="lib_Contentbox"> <div id="con_one_1" ><div class="ss">1</div></div> <div id="con_one_2" style="display:none"><div class="ss"><a name="sss" id="sss"> </a>帮帮me....</div></div></div></div></div></div><div class="a5"> <a href="#sss" onclick="theforever()">clickme </a> </div></body> </html><script>function setTab(name,cursel,n){ for(i=1;i<=n;i++){ var menu=document.getElementById(name+i); var con=document.getElementById("con_"+name+"_"+i); menu.className=i==cursel?"hover":""; con.style.display=i==cursel?"block":"none"; }} function theforever(){document.getElementById("con_one_2").style.display = "block";document.getElementById("con_one_1").style.display = "none";document.getElementById("one2").className = "hover";document.getElementById("one1").className = "";document.getElementById("sss").focus();document.getElementById('sss').parentNode.style.backgroundColor='#E4F2FD'; } </script></html> html与sencha touch组件怎么结合使用 帮帮我 js删除动态表格行 新手提问showModalDialog传值问题 SELECT盖住了DIV,改了好几天了,写iframe搞不定啊 firefox下怎样使内容超过宽度自动分行 请问如何判断一个String里是否包含@呢? 关闭父页面和子页面的问题 如何判断用户点击了mediaplayer自带的暂停和播放按钮 matlab写的gui可以转换成web网页显示吗 求助,利用JS实现在页面载入时候的类似验证码的功能 JS数组中怎么不区分大小写排序?
这个可以,但是聚焦的话就像1楼说的不能聚焦到DIV上的
function theforever()
{
document.getElementById("con_one_2").style.display = "block";
document.getElementById("con_one_1").style.display = "none";
document.getElementById("sss").focus();
document.getElementById('sss').parentNode.style.backgroundColor='#E4F2FD';
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><style type="text/css">
#lib_Tab1{
margin:0px;
padding:0px;
height: 77px;
width: 250px;
}
.lib_Contentbox{
text-align:left;
width: 200px;
float: left;
height: 50px;
border: thin solid #00CC33;
}
.lib_Menubox {
height:20px;
line-height:20px;
width: 200px;
}
.lib_Menubox li{
float:left;
display:block;
cursor:pointer;
width:60px;
font-weight:bold;
height:20px;
line-height:20px;
font-size: 10pt;
background-color: #6699CC;
}
.lib_Menubox ul{
padding:0px;
list-style:none;
left:-5px;
height:20px;
text-align:center;
z-index: 99;
margin: 0px;
}
.lib_Menubox li.hover{
padding:0px;
background:#fff;
width:60px;
color:#739242;
height:20px;
line-height:20px;
border: 1px solid #95C9E1;
position: relative;
}
.ss{
height: 40px;
width: 100px;
float: left;
margin-left: 10px;
border: thin solid #009933;
} .a5{
height: 30px;
width: 50px;
border: thin solid #000000;
top: 100px;
position: relative;
}
--></style><body>
<div id="lib_Tab1">
<div class="lib_Menubox">
<ul>
<li id="one1" onclick="setTab('one',1,2)" class="hover">新闻1</li>
<li id="one2" onclick="setTab('one',2,2)" >新闻2</li>
</ul>
</div>
<div class="lib_Contentbox">
<div id="con_one_1" ><div class="ss">1</div></div>
<div id="con_one_2" style="display:none"><div class="ss"><a name="sss" id="sss"> </a>帮帮me....</div></div>
</div>
</div>
</div></div>
<div class="a5"> <a href="#sss" onclick="theforever()">clickme </a> </div>
</body> </html><script>
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}
function theforever()
{
document.getElementById("con_one_2").style.display = "block";
document.getElementById("con_one_1").style.display = "none";
document.getElementById("one2").className = "hover";
document.getElementById("one1").className = "";
document.getElementById("sss").focus();
document.getElementById('sss').parentNode.style.backgroundColor='#E4F2FD';
}
</script>
</html>