简体   繁体   English

单击图标图像显示电子邮件注册表单

[英]Displaying E-mail Sign up form on clicking icon image

I'm trying to have an e-mail submission form box appear when visitors click a little envelope icon at the top right of my page, but I can't seem to get ti to work--either it appears in the middle of a bunch of icons or it doesn't appear at all. 当访问者单击页面右上角的信封图标时,我试图显示一个电子邮件提交表单框,但是我似乎无法正常工作-要么出现在电子邮件的中间一堆图标,或者根本不显示。 Ideally I would love for it to show up just underneath the row of icons (see attached image). 理想情况下,我希望它显示在图标行的下方(请参见附件图像)。 I'm extremely new to all of this, so thank you in advance for your patience :) 我对这一切都非常陌生,所以在此先感谢您的耐心配合:)

Here's the HTML (the 这是HTML(

  • li is within the and accompanies three other icons): li位于内,并带有其他三个图标):

     <li> <div class="email-form"><img src="<?php echo $site_url;?>img/nav/emailicon.png?v=2" alt="E-mail Sign Up" width="23" height="23" id="email-icon" style="display: inline;"/><form class="email-form" action="subscribelink" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank" style="display: none;"><fieldset><input type="text" name="EMAIL" value="YOUR EMAIL ADDRESS" /> <input type="submit" value="Submit" /> </div> <div class="email-response" style="display: none;">Thank You</p></fieldset></form> </li> </div> </a> 

    the css: CSS:

      nav.email-form{ display:none; } 

    and the js: 和js:

     $(function(){ $('.email-icon').on('click', function(e){ e.preventDefault(); $(this).next('.email-form').show(); }); }); 
  • Well you can position your form container absolutely (or fixed). 好吧,您可以完全(或固定)放置表单容器。 Something like this: 像这样:

    .email-form form {
        display: none;
        position: absolute;
        top: 0;
        right: 0;
    }
    

    And then you some simple javascript to toggle it: 然后您可以使用一些简单的JavaScript进行切换:

    $('#email-icon').click(function() {
        $('#mc-embedded-subscribe-form').show();
    });
    

    Demo: http://jsfiddle.net/2RCw4/ 演示: http//jsfiddle.net/2RCw4/

    I would also not recommend you to use methods like .next() , because if you change markup it will stop working. 我也不建议您使用.next()类的方法,因为如果更改标记,它将停止工作。

    I agree with dfsq, but instead of using .click() and .show() I would recommend the jQuery function .fadeToggle(). 我同意dfsq,但建议使用jQuery函数.fadeToggle(),而不是使用.click()和.show()。 I assume that if you are going to want to show something, you are also going to want to hide it again. 我假设如果您要显示某些东西,那么您也将要再次隐藏它。

    $('#email-icon').click(function() {
       $('#mc-embedded-subscribe-form').fadeToggle();
    });
    

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM