I have me at a standstill. I use the βforβ attribute on some links to identify the element on which they should act. Everything seems to work fine in Firefox, IE9 and IE8 ... but IE7 breaks and returns "undefined."
Here is the gist of the jQuery code I'm using:
$(document.ready(function() { var editor_icons = $('.edit-button'); editor_icons.each(function() { var $this = $(this), parent = $('#' + $this.attr('for')); var left = parent.position().left + parent.innerWidth() - 58 - 3, top = parent.position().top + 3;
An example of an HTML element that it should act on:
<div id="content_wrapper"> <a class="edit-button" href="javascript:void(0);" for="index_primary_content" /> <div id="index_primary_content"> .... </div> </div>
Before pointing this out, I understand that anchors should not be automatically closing elements. The HTML I am sending from my application is <a></a> , and IE interprets it as <a /> . I added between the elements to make sure that this is not a problem of interpretation, and I get the same error.
The problem is that $this.attr('for') returns "undefined", so parent.position().left throws the error "object is null or undefined".
I dug up the clock variables a bit, and I see that the selectors work, and $this in this context selects the right elements and has a set of attributes for "... but jQuery isn 'I think I think.
As I said, it works fine in Firefox, IE9 and IE8 ... just not IE7. Ideas?
For reference, I am using jQuery 1.6.2 ...
source share