如何获取以上div的ID? [英] How to get the id of above div?
本文介绍了如何获取以上div的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取已知div之上的已知div的div ID.
How to get the div id of the known div which is above the known divid.
推荐答案
我尝试了一些您需要的东西
Hi,
I tried something for your requirement
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language ="javascript" >
(文档).ready(函数(av){ }); 函数 getid(tid){ alert(文档 .getElementById(tid).previousSibling.id); } < / 脚本 > < /head > < 正文 > < 表单 =" form1" runat >服务器" > < div =" maincontent" < div =" frstdiv" < > < div =" scnddiv" onclick getid(此.id)" < > < /div > < /form > < /body > < /html > < /html >
(document).ready(function (av) { }); function getid(tid) { alert(document.getElementById(tid).previousSibling.id); } </script> </head> <body> <form id="form1" runat="server"> <div id="maincontent"> <div id="frstdiv">this is first div tag</div> <div id="scnddiv" onclick="getid(this.id)">this is second div</div> </div> </form> </body> </html></html>
最好的
All the Best
更具体以获得适当的答案
如果您想使用javascript访问divid,请使用此
Be more specific to get appropriate answer
if you want to access divid in javascript then use this
var divid=document.getElementById('<%=divid.ClientID %>');
这篇关于如何获取以上div的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文