Last active
September 8, 2015 08:48
-
-
Save s0ren/f125a22f51d71d7b7f34 to your computer and use it in GitHub Desktop.
Hvordan man gennemløber flere elementer i jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$("button").click(function(){ | |
$("p").each(function(){ | |
var x = $(this).position(); | |
alert("Top position: " + x.top + " Left position: " + x.left); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<p>This is a paragraph.</p> | |
<p> ... and this en anden paragraf </p> | |
<button>Return the top and left position of the p element</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment