开发者

JQuery Event.target problem in ie7

开发者 https://www.devze.com 2022-12-13 04:38 出处:网络
Tryi开发者_高级运维ng to accses the class name from the event.target object.Works in FF, Safari, and Chrome.InternetExplorer 7 alerts \"undefined\".Any suggestions?

Tryi开发者_高级运维ng to accses the class name from the event.target object. Works in FF, Safari, and Chrome. InternetExplorer 7 alerts "undefined". Any suggestions?

<script type="text/javascript">
 $("document").ready(function(){ 
  $(".page").hide();
  $(".page:first").show();
  $("#navBar a").bind("click", linkClicked);
 });
 function linkClicked(event){
   $("div.page:visible").fadeOut(250, function(){
    var $target = $(event.target);
    alert($target.attr("class"));
    //$("#" + $(event.target).attr("class")).fadeIn(250);
   }); 
 }
</script>


Found a solution. Set the event.target to a var before the callback for fade out. :p any idea why?

<script type="text/javascript">
 $("document").ready(function(){ 
  $("#content").css("opacity","0.8");
  $(".page").hide();
  $(".page:first").show();
  $("#navBar a").bind("click", linkClicked);
 });
 function linkClicked(event){
  var $target = $(event.target);
  $("div.page:visible").fadeOut(250, function(){
   alert($target.attr("class"));
   //$("#" + $(event.target).attr("class")).fadeIn(250);
 });    
 }
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消