【问题标题】:javascript/jquery - Hide element in parent tab controlled from pop up window part 2javascript/jquery - 在弹出窗口第 2 部分控制的父选项卡中隐藏元素
【发布时间】:2013-03-06 14:10:11
【问题描述】:

有人可以帮我解决这个问题吗? 我有一个父窗口和一个弹出窗口。我希望他们交流,但代码有问题。请告诉我有关 javascript 或 jquery 的信息。我只是想让弹出窗口也控制父窗口。

我的 index.html

<html>
<head>
<script>
function openwindow() { window.open("pop.html","mywindow","menubar=1,resizable=1,width=400,height=400"); }
</script>
</head>
<body>
<a href="href="javascript: openwindow()"" id="will-hide-in-pop">Show pop up!</a>
</body>
</html>

然后我们点击锚点后,弹出窗口将显示。这是带有表单的弹出代码: 弹出代码:

<html>
<head>
<script>
function clicked(){window.opener.document.getElementById('will-hide-in-pop').style.display="none"; }
</script>
</head>
<body>
<div>
<form action="process.php" method="GET">
<input type="text" name="text" />
<input type="checkbox" name="cbox" />
<input type="submit" name="" onclick="clicked()"/>
</form>
</div>
</body>
</html>

我输入了正确的代码吗? 我只想要表单提交了,父窗口中的锚点也会消失

请帮帮我

【问题讨论】:

    标签: javascript jquery popup parent


    【解决方案1】:

    尝试在 jQuery 提交中调用您的函数:

     $(document).ready(function () {
         $('form').submit(function () {
             clicked();             
          });       
     });
    

    【讨论】:

      【解决方案2】:

      注意选择器:.getElementById('will-hide-in-pop') 在弹出窗口中,您使用 getElementById,但在索引中,有 class="will-hide-in-pop"。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-25
        • 1970-01-01
        • 2020-07-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多