{"id":3643,"date":"2014-03-29T07:23:43","date_gmt":"2014-03-29T07:23:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/position-top-is-null-or-not-an-object-collection-of-common-programming-errors\/"},"modified":"2014-03-29T07:23:43","modified_gmt":"2014-03-29T07:23:43","slug":"position-top-is-null-or-not-an-object-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/29\/position-top-is-null-or-not-an-object-collection-of-common-programming-errors\/","title":{"rendered":"&#39;position().top&#39; is null or not an object?-Collection of common programming errors"},"content":{"rendered":"<p>Your .css() arguments are backwards; it should be <code>.css(, )<\/code><\/p>\n<pre><code>$('#pnlAdd .modalDialog').css(\"top\", $(\"tr [style*=Blue]\").position().top + \"px\");\n<\/code><\/pre>\n<p>Also, <code>.position()<\/code> will return null if <code>$(\"tr [style*=Blue]\")<\/code> doesn&#8217;t return anything, causing an error. Try checking its length first.<\/p>\n<pre><code>var elements = $(\"tr [style*=Blue]\");\nif (elements.length) {\n    $('#pnlAdd .modalDialog').css(\"top\", elements.position().top + \"px\");\n}\n<\/code><\/pre>\n<p><strong>EDIT NOTE<\/strong> Firefox use initial caps on the colors (Blue) but IE use all lowercase (blue).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your .css() arguments are backwards; it should be .css(, ) $(&#8216;#pnlAdd .modalDialog&#8217;).css(&#8220;top&#8221;, $(&#8220;tr [style*=Blue]&#8221;).position().top + &#8220;px&#8221;); Also, .position() will return null if $(&#8220;tr [style*=Blue]&#8221;) doesn&#8217;t return anything, causing an error. Try checking its length first. var elements = $(&#8220;tr [style*=Blue]&#8221;); if (elements.length) { $(&#8216;#pnlAdd .modalDialog&#8217;).css(&#8220;top&#8221;, elements.position().top + &#8220;px&#8221;); } EDIT NOTE Firefox use initial caps [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3643","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3643"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3643\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}