Y Position of an Element
Find the location of an element on the page.
Using jQuery, it's easy to find out exactly where an element is on the page. Simply use jQuery's position() function:
<script>
var p = $( "h2" );
var position = p.position();
$( "p:last" ).text( "left: " + position.left + ", top: " + position.top );
</script>
Using the Coordination plane terminology, the position "top" is the Y-axis and "left" is the X-axis.
By default the position() method returns the first instance of the element. The position is relative to the parent element.
Why is this Important for QA testing?
This would be useful if you need to verify an element is in a particular location on the page, for example, to make sure that the footer logo has enough headroom in the Div tag.
Why this Posting?
Today's A-Z challenge letter is 'Y.' This is not an easy topic, as there's really not many tools that begin with the letter 'Y' for jQuery and QA.
This will be the last post for jQuery for a while. On Monday's in May I'll switch back to focus on general QA topics.