3

Trying 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>

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

1 Comment

My guess, once the fading animation starts, the IE7's DOM event handling screwed up (at least temporarily), hence it can't return the 'target' it is 'animating' then. Glad you found a work-a-round. Btw, do accept your own answer :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.