Currently using:
$(function () {
$(".playbtn").on("button", "click", function (e) {
var title = $(this).attr('name');
});
});
$('.movie-title').html(title);
I am trying to get the content of name for playbtn on click and store it in a variable. Then put this content into a div.
delegated element selectoris in the wrong place. Should beIF you want to use that variable inside another function you need to make a global use of your
varlike:Read more: jquery.com/on
Post Scriptum:
Be aware that the above will target all elements
.movie-titleso be more specific using your jQuery selectors:jquery.com/selectors jquery.com/traversing