Created
September 15, 2015 13:27
-
-
Save s0ren/a84fe3d0bdc42f0dd831 to your computer and use it in GitHub Desktop.
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(); | |
var hiddenInput = $("<input>", {type: "hidden", name: this.id, value: this.innerText }); | |
$("#theForm").append(hiddenInput); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<p id="first">This is a paragraph.</p> | |
<p id="2"> ... and this en anden paragraf </p> | |
<button>Return the top and left position of the p element, and add to the form</button> | |
<form id="theForm"> | |
<input type="submit"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment