Good day, I'm working with a calendar that is generated with Jquery then generates a table that brings a few years. I attach an image of how it looks:
The table is generated dynamically, creating this code:
<div id="calendar">
<div class="calendar-header panel panel-default">
<table>
<th class="prev"><span class="glyphicon glyphicon-chevron-left"></span></th>
<th class="year-title year-neighbor2 hidden-sm hidden-xs">2016</th>
<th class="year-title year-neighbor hidden-xs">2017</th>
<th class="year-title">2018</th>
<th class="year-title year-neighbor hidden-xs">2019</th>
<th class="year-title year-neighbor2 hidden-sm hidden-xs">2020</th>
<th class="next"><span class="glyphicon glyphicon-chevron-right"></span></th>
</table>
</div>
With this function I want to bring that value, the alert does not show anything at the moment of the click:
$("table th").click(function(){
var x=($(this).html());
alert(x);
});
But it does not bring it, I want to suppose that it is because the code is not in the document, but it is generated. Is there any way to bring that value? I'm using bootstrap-years-calendar