2014-12-06 72 views
-2

美好的一天先生。幫我解決這個問題。這個代碼只是在我打開頁面時自動彈出。我怎樣才能將其轉換爲可點擊而不是自動彈出。JavaScript可點擊圖標代替彈出

<script type="text/javascript" src="//www.klaviyo.com/media/js/public/klaviyo_subscribe.js"> </script> 

    <script type="text/javascript"> 

    KlaviyoSubscribe.attachModalSignUp({ 
     list: 'g9cZtX', 
     delay_seconds: 0.5, 
     content: { 
      clazz: ' klaviyo_modal_g9cZtX', 
      header: "Interested in our Newsletter?", 
      subheader: "Stay in the know with news and promotions.", 
      button: "Subscribe", 
      success: "Thanks! Check your email for a confirmation.", 
      styles: '.klaviyo_modal.klaviyo_modal_g9cZtX { font-family: "Helvetica Neue", Arial}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_header { color:#222;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_subheader { color:#222;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button span { background-color:#07234F; background-image: none; border-radius: 2px;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button:hover,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button span:hover { background-color:#2A4D85; background-image: none; }.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_inner,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_fieldset .klaviyo_field_group input[type=text],.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_fieldset .klaviyo_field_group input[type=email] { border-radius: 2px;}' 
     } 
    }); 

這裏是點擊圖標

<li><a href="#"><i class="icon-envelope icon-2x"></i></a></li> 

幫助我摸不着頭腦。 在此先感謝

回答

0

使用點擊()這樣做或使用。對(「點擊」)..這樣的改變你的類icon_png代替的icon.png

$(document).ready(function(){ 
    $('.icon_png').on('click',function(){ 
    KlaviyoSubscribe.attachModalSignUp({ 
      list: 'g9cZtX', 
      delay_seconds: 0.5, 
      content: { 
       clazz: ' klaviyo_modal_g9cZtX', 
       header: "Interested in our Newsletter?", 
       subheader: "Stay in the know with news and promotions.", 
       button: "Subscribe", 
       success: "Thanks! Check your email for a confirmation.", 
       styles: '.klaviyo_modal.klaviyo_modal_g9cZtX { font-family: "Helvetica Neue", Arial}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_header { color:#222;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_subheader { color:#222;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button span { background-color:#07234F; background-image: none; border-radius: 2px;}.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button:hover,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_submit_button span:hover { background-color:#2A4D85; background-image: none; }.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_inner,.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_fieldset .klaviyo_field_group input[type=text],.klaviyo_modal.klaviyo_modal_g9cZtX .klaviyo_fieldset .klaviyo_field_group input[type=email] { border-radius: 2px;}' 
      } 
     }); 
    }); 
    }); 
+0

選擇必須是' .icon \\。png' – 2014-12-06 13:05:08

+0

@ Dr.Molle謝謝我更新我的回答 – 2014-12-06 13:07:02

+0

@ Dr.Molle很好的編輯。但我不想讓OP不知道點擊事件,他怎麼能理解這個斜槓..我不希望他以後會變得困惑:) – 2014-12-06 13:31:56