<button onclick="alert('Hello!')" id="btn"> Click me </button>
Note: if you're not interested in the process :-| , go straight to the code ↓ you can copy-paste.
alert( $("#btn").html() ); // Click to run ->
If the button were the single child and only content of another element, calling html() would give us our button's outerHTML, not just its innerHTML (which in this case is just the button's text).alert( $("#btn").wrap("<div>").parent().html() ); // Try it ->
$("#btn").clone(); // copy of our button created in memory
$.fn.outerHTML=function(){return $('<div>').append(this.eq(0).clone()).html()}