Here is some dynamically generated content with jquery.
<div id="response">
    <button id="high" class="btn-key-main">high</button>
    <button id="last" class="btn-key-main">last</button>
</div>
How do I get the content of the button that is clicked (high or last) in a div with id="solution"? Here's what I tried:
$("#response").on("click", 'button.btn-key-main', function() {
    $("#solution").html($(this).val());
});
Solved by @slicedtoad and @smerny
.val() should've been .html() or .text()
$("#solution").html($(this).html());
    
responsealso generated? if so you'll have to either add the listener after creating it or use delegation from a parent that exists at load timetext()$(this).val()to$(this).html()... ortext()as I see slicedtoad beat me to this (your buttons do not have values)