SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup not working in IE7 and IE8

    Got the following code for a project I'm working on but the JavaScript isnt working in IE7 and IE8

    Code:
    <script type="text/javascript">
    var drinks = ['rum', 'le', 'montingo', 'tingquila', 'passionate'];
    
    function openDrink(e) {
      $("div." + e.data).fadeIn("slow");
    }
    
    $(document).ready(function() {
      $.each(drinks, function(i, el) {
        $("div." + el + " > img.close").click(function(tar) {
          $(tar.currentTarget).parent().fadeOut("slow");
        });
        $('img.' + el).click(el, openDrink);
      });
    });
    </script>
    anyone know of a fix for this.
    thanks in advance

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    IE 7 & 8 don't support the event.currentTarget property so instead you have to use event.srcElement for IE, see the updated code below.

    Code JavaScript:
    $(tar.currentTarget ? tar.currentTarget : tar.srcElement).parent().fadeOut("slow");

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you SgtLegend worked a treat, also good to know for future products!!

  4. #4
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Another shortcut for the current element inside a Jquery event handler is $(this) ... e.g.

    Code:
    $("#links li a").click(function(){ 
      $(this).parent(); // points to the parent li of the clicked link
    });
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •