Skip to content

Instantly share code, notes, and snippets.

@s0ren
Created September 15, 2015 13:27
Show Gist options
  • Save s0ren/a84fe3d0bdc42f0dd831 to your computer and use it in GitHub Desktop.
Save s0ren/a84fe3d0bdc42f0dd831 to your computer and use it in GitHub Desktop.
<!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