views:

45

answers:

2

Here's the snippet of code that I'm using to animate a div with jQuery:

        $('.row0').hover(function(){
     var markeranim = $('.marker0');
     var shadowanim = $('.markerShadow0')
     var markertop = markeranim.position().top;
     var shadowtop = shadowanim.position().top;
     var shadowleft = shadowanim.position().left;
      $('tr.row0').addClass('rowHoveredEven');
       markeranim.animate({ top: [markertop - 20 + 'px'] }, 250, 'linear',
function() {
                    markeranim.animate({ top: [markertop + 'px'] }, 250, 'linear',
function() {
                        markeranim.animate({ top: [markertop - 10 + 'px'] }, 200,
'linear', function() {
                            markeranim.animate({ top: [markertop + 'px'] }, 200);
                        });
                    });
                });//close animation

This works great in all browsers but IE (of course). IE gives an error saying that: "'position().top' is null or not an object" along with: "'position().left' is null or not an object". Anyone know why or another way that I could grab these attributes that IE would play nice with?

A: 

The .position() dimensions plugin has been deprecated as of 1.2.6, use .css() instead:

var myTop = markeranim.css("top");
var myLeft = markeranim.css("left");

http://docs.jquery.com/Plugins/dimensions

David
I'd like to get the css values not assign them? Isn't assignation what you're talking about here?
abemonkey
Sorry, ill update for get.
David
@David - `.position()` isn't a plugin, it's in [jQuery core](http://api.jquery.com/position/) :)
Nick Craver
@Nick Craver, you are right, I misunderstood the comments in the documentation link above, hopefully .css() solves the problem anyway.
David
@ Nick: The I'm using another function earlier in my script to add the class to the div that I'm inspecting. This is in a google maps application I'm working on what I DIDN'T realize was that the dom structure for how google puts markers onto the map is totally different for IE so I was assuming that the divs with the markers had those classes when they didn't. Hope that makes sense. It's back to the drawing board on how to classify the appropriate divs in IE now. Once I figure that out my animation function will work just fine (I did some testing to prove this in IE). Thanks!
abemonkey
A: 

have you tried checking to see if markeranim is null?

Boris Lutskovsky
tried this and it was. The I'm using another function earlier in my script to add the class to the div that I'm inspecting. This is in a google maps application I'm working on what I DIDN'T realize was that the dom structure for how google puts markers onto the map is totally different for IE so I was assuming that the divs with the markers had those classes when they didn't. Hope that makes sense. It's back to the drawing board on how to classify the appropriate divs in IE now. Once I figure that out my animation function will work just fine (I did some testing to prove this in IE). Thanks!
abemonkey