I am working on a very old legacy project. On this project is included a very old JQuery version (the 1.2.3 version). I can't change the JQuery version.
I am finding some difficulties to do the following operation.
In my script I have to check if a specific element has certain CSS class setted, so in my code I have something like this:
var theadElement = $(this);
if(theadClass.hasClass('active')) {
alert("THEAD ACTIVE");
}else {
alert("THEAD NOT ACTIVE");
}
So the theadElement contain the reference of a thead tag retrieved from my DOM (this works fine) and I have to check if this thead tag have setted a CSS class named active.
I tryied to use the hasClass() function as shown here: Jquery: How to check if the element has certain css class/style
But when it try to performe the hasClass() function it can't work and I obtain the following error message into the FireBug console:
TypeError: theadClass.hasClass is not a function
http://localhost:7001/wea-web/edi.do?serv=8.2
Line 47
So I think that the problem could be that the JQuery 1.2.3 version is too old and the hasClass() function is not implemented in this version.
What can I do to solve this issue in an alternative way? How can I check if the active CSS class is setted on the selected element?
EDIT-1: This is my entire script:
$(document).ready(function () {
$("thead.opening").click(function () {
alert("INTO FIRST FUNCTION !!!");
//alert($(this).next().css('display'));
var theadElement = $(this);
var tbodyElement = $(this).next();
alert("THEAD TAG BEFORE: " + theadElement.attr('tagName'));
var theadClass = theadElement.attr('class');
alert("CLASS THEAD BEFORE: " + theadClass);
$(this).next().slideToggle('slow', function () {
$(this).prev("thead.opening").toggleClass("active");
$("thead.opening").find(".imgAccordion").attr("src", "img/arrow.gif");
$("thead.active").find(".imgAccordion").attr("src", "img/arrow_down.gif");
alert("THEAD TAG AFTER: " + theadElement[0].tagName);
// Retrieve the class of the clicked thead element in the DOM:
var theadClass = theadElement.attr('class');
alert("CLASS THEAD AFTER: " + theadClass);
if(theadClass.attr('class').match(/active/)) {
alert("THEAD ACTIVE");
}
else {
alert("THEAD NOT ACTIVE");
}
});
return false;
});
Tnx