I have two functions, one that will show a window and one that will hide a window. When the window is first created it will create a tab like link at the top of the page. What I'm wanting to do is when the user clicks that tab it will hide the window and if pressed again it will show the window. How do I determine if the window is open or closed?
我有两个功能,一个用于显示窗口,另一个用于隐藏窗口。首次创建窗口时,它将在页面顶部创建一个类似链接的选项卡。我想要做的是当用户点击该选项卡时它将隐藏窗口,如果再次按下它将显示窗口。如何确定窗口是打开还是关闭?
Basically the window will be created and added to the navbar
基本上,窗口将被创建并添加到导航栏中
<li onclick='tabWindowOpen(window.name)'>" + name + "</li>
Then on click it will call the function tabWindowOpen
然后单击它将调用函数tabWindowOpen
function tabWindowOpen(name) {
if(// it hasnt been click) {
hideWindow(name);
}
else if (// it has been clicked) {
showWindow(name);
}
}
Any ideas?
1 个解决方案
#1
jQuery does that for you, and you should be using event handlers:
jQuery为你做到了,你应该使用事件处理程序:
'<li class="my-li-class">' + name + '</li>'
$(document).on('click', '.my-li-class', function(window.name) {
$(window.name).toggle();
});
#1
jQuery does that for you, and you should be using event handlers:
jQuery为你做到了,你应该使用事件处理程序:
'<li class="my-li-class">' + name + '</li>'
$(document).on('click', '.my-li-class', function(window.name) {
$(window.name).toggle();
});