下拉栏在第二次单击(在输入框中)时恢复,因为它位于动画 div 内 - jquery

发布于 2024-12-28 23:53:33 字数 1005 浏览 1 评论 0原文

目前我有这个

            <div id="beau">

                <div>
                <input type="text" id="lun" name="lun" size="24" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'User Name':this.value;" value="User Name"             
                style="position:absolute; background-color:transparent; border-style:none; margin-top:53px; margin-left:35px;" />
                </div>

                <img src="_images/Rollovers/drop bar export.png" alt="extras" width="877" height="160" border="0" />

            </div> 


        <script type='text/javascript'>

    $("#beau").toggle(function(){
        $(this).stop().animate({marginTop: 738}, "fast");
    }, function() {
        $(this).stop().animate({marginTop: 680}, "fast");
    });

        </script>

问题,问题是,我将单击“beau”div 下拉“输入框”和图像(都在“beau”div 内)并且一切正常,但是当我单击“输入框”输入文本,下拉栏再次返回。我知道它为什么这样做,并且我尝试了一些方法来让它工作,但我就是无法得到它。感谢你们所有的帮助:)

at the moment i have this

            <div id="beau">

                <div>
                <input type="text" id="lun" name="lun" size="24" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'User Name':this.value;" value="User Name"             
                style="position:absolute; background-color:transparent; border-style:none; margin-top:53px; margin-left:35px;" />
                </div>

                <img src="_images/Rollovers/drop bar export.png" alt="extras" width="877" height="160" border="0" />

            </div> 


        <script type='text/javascript'>

    $("#beau").toggle(function(){
        $(this).stop().animate({marginTop: 738}, "fast");
    }, function() {
        $(this).stop().animate({marginTop: 680}, "fast");
    });

        </script>

and what the problem is, is that i will click the "beau" div to drop down the "input box" and the image (both inside the "beau" div) and that all works fine but but when i click in the "input box" to type text the drop bar goes back up again. i know why it does it and I've tried a few things to get it working but i just can't get it. thanks for all your help guys :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放赐 2025-01-04 23:53:33

一种选择是为输入添加一个处理程序,以停止传播到 div:

    $('#lun').click(function(e){
       e.stopPropagation(); 
    });

One option is to add a handler for the input that stops propagation to the div:

    $('#lun').click(function(e){
       e.stopPropagation(); 
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文