当我将鼠标移动到容器面板上时,会显示子面板,但只要将鼠标移到子面板上,便会触发mouseout事件并隐藏面板。防止没有Jquery的冒泡
这是我的代码的简化版本,因为面板位于gridview内,因此我不能像原样使用document.getElementById(“panelchild”)(js会得到特定的id后者),但现在我想让它适用于这个简单的案例。
这是部分脚本:
<script type="text/javascript">
function ShowPanel(e) {
// e = e || window.event;
// var evtSrc = e.target || e.srcElement;
var panel = document.getElementById("panelchild")
if (panel.style.display == "none")
panel.style.display = "";
else
panel.style.display = "none";
}
</script>
这是标记:
<asp:Panel id="panelContainer" runat="server" onmouseover="ShowPanel(event)" onmouseout="ShowPanel(event)" >
<asp:HyperLink ID="lnkTitle" runat="server" style="float:left;margin-right:10px;" Text="This is title" NavigateUrl="www" />
<asp:Panel id="panelchild" runat="server" style="display:none" >
<a id="A1" href="javascript: void(0);" style="text-decoration: none;">
<img src="mylocalsite/images/Misc_Edit.gif" style="border:0px;float:left;" />
</a>
</asp:Panel>
</asp:Panel>
你想达到什么?只要panelChild位于panelContainer内部,您就可以做的事情不多。 – 2010-03-17 12:45:33
我可以将chidpanel移动到外面,但是,我必须将事件也添加到孩子。 – mariki 2010-03-17 12:59:57
为什么你拒绝使用jQuery,如果你正在使用其他框架,它可能使用jQuery以及使用noconflict(); – ant 2010-03-17 13:08:44