I have a challenge in extracting text enclosed within the `Label
` tag. My knowledge of Javascript and JQuery is limited, so I require guidance on accomplishing this task. Currently, I am attempting to use code that I found on a stackoverflow post titled get-values-from-label-using-jquery
<label year="2010" month="6" id="currentMonth"> June 2010</label>
var label = $('#currentMonth');
var month = label.attr('month');
var year = label.attr('year');
var text = label.text();
The issue I am facing with this code is that it ceases to function when I remove the ID element. I seek advice on how to make it work without relying on the ID attribute.