2017-04-07 7 views
1

私はこのスクリプトを試しましたが、2番目の指定IDで動作しませんでした。 両要素は、私は、次のコードが、ない成功を試みIFRAMEJquery multiple ID selectorが機能しません

<script> 
    jQuery(document).ready(function(){ 

     $("#subscribe_newsletter, #close_bar").each(function(){ 
      $(this).click(function(){ 
       alert("with each"); 
       $.cookie("nl_cookie" , 1 , { path: "/" }); 
       $("#footer_accept_newsletter").hide("slow"); 
      }); 
     }); 
     cookieValue = $.cookie("nl_cookie" , { path: "/" }); 

     if(!cookieValue){ 
      $("#footer_accept_newsletter").removeClass("hidden"); 
     } 
    }); 
</script> 

内側にあります。

$("#subscribe_newsletter, #close_bar").click(function(){ 
    $.cookie("nl_cookie" , 1 , { path: "/" }); 
    $("#footer_accept_newsletter").hide("slow"); 
}); 
+0

はこの試してみてくださいそれをチェックしてください私のために働く: 'jQuery.each([ "#のsubscribe_newsletter"、 "#close_bar"]、機能(I、id)を{$(id).click(function(){...})}) ' – Abhi

答えて

0

それは

$(document).ready(function(){ 
    $("#segement1, #segement2, #segement3").click(function(){ 
    alert($(this).attr("id")); 
    }); 
}); 

FIDDLE

関連する問題