I am encountering difficulties in obtaining the class of my div elements, which are intended to function as tabs on a simple asp.net website. I aim to achieve this using jQuery for better control over dynamic functions in the future. However, every time I attempt to retrieve the value of the specific "selectedTab", all I receive is "undefined".
My query revolves around how I can effectively store the relevant class alongside the name of that object (which, according to my code, seems accurate), and subsequently access it.
Here are the key sections of my basic HTML structure:
<div id="t1" class="tabs"></div>
<div id="t2" class="tabs"></div>
<div id="t3" class="selectedTab"></div>
<p></p>
Below is the snippet of jQuery used:
var tabMatchList = [{
"tab1": "tabs"
}, {
"tab2": "tabs"
}, {
"tab3": "selectedTab"
}];
$.each(tabMatchList, function (i, val) {
if ($("#t3").attr("class") == val[0]) {
$("p").append(i + " was the tab searched for");
} else {
$("p").append(i + " was not the tab searched for." + val[0]);
}
});
I appreciate any assistance or guidance provided regarding this matter.