我又来送分了 关于标签下查询自标签的问题

shuoyangtt 2011-09-07 02:16:12
上代码...请问我 document.getElementByName("show")可以取到c标签对吧 但现在我想取a标签的style元素的值 我ok方法应该怎么写

<c id =<%= i%> name="show">
<b id=<%=m%>>
<a href="#" style="abc">
</a>
</b>
</c>

<script type=text/javascript>
function ok() {
document.getElementByName("show").

}
</script>
...全文
146 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuoyangtt 2011-09-07
  • 打赏
  • 举报
回复
回三楼啊
还是跑不起来啊
001007009 2011-09-07
  • 打赏
  • 举报
回复

<c name="show">
<b>
<a href="#" style="abc">
</a>
</b>
</c>

<script type=text/javascript>
function ok() {
obj=document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style');
alert(obj);
}
ok()
</script>

shuoyangtt 2011-09-07
  • 打赏
  • 举报
回复
回三楼
我javascrpt里声明
var obj =""
function ok() {
alert("sadasd");
obj=document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style');
alert(obj);

}

出错 alert弹不出来 对象应该没取到 你再给看看把
001007009 2011-09-07
  • 打赏
  • 举报
回复
document.getElementsByName("show")[0].getElementsByTagName("a")[0].getAttribute('style')
挨踢直男 2011-09-07
  • 打赏
  • 举报
回复
function ok() {
document.getElementByName("show")[0].style
}

style是个对象访问他的属性可以 xx.style.width 这个样子
TianXiaoJunTT 2011-09-07
  • 打赏
  • 举报
回复
<a id="a1" href="#" style="abc"></a>
document.getElementById("a1").style.display = 'none';

87,990

社区成员

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

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