Jump to content

Hasclass() Undefined When Using Variable


Costanza

Recommended Posts

I just started converting my code to jQuery syntax (I've already linked the file and it's working) and I'm getting this error:

TypeError: Result of expression 'currentElement.hasClass' [undefined] is not a function.

on this line:

if (currentElement.hasClass('is228'))

The relevant code in order (well, what I think is relevant since it is the only code that executes up to this point):

equip($('#barrel_228mm')[0]);

function equip(currentElement){if (!equippingNone) //to prevent infinite loop{removeMultiCategoryCopies();}if (window.getComputedStyle){$('#' + currentCategory)[0].style.backgroundImage = getComputedStyle(currentElement).getPropertyValue("background-Image");}else{$('#' + currentCategory).style.backgroundImage = currentElement.currentStyle.backgroundImage;}$('#' + currentCategory)[0].className = currentElement.className;$('#' + currentCategory).addClass('equipItem');$('#' + currentCategory)[0].title = currentElement.title;hideOptions(currentCategory);fixLowerPriorities(currentElement);currentCategory = 'none';}

The function that fails (shown to the line that gets the error):

function fixLowerPriorities(currentElement) //return true means to continue to equip{//******Begin Barrelif ($('#' + currentCategory).hasClass('barrel')){alert(currentElement);var compType;if (currentElement.hasClass('is228'))

As you can see, the element itself is passed into the function "fixLowerPriorities()" and becomes "currentElement" so I should be able to just use hasClass() like I am, right? What is my mistake? Thank you for your help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...