Costanza Posted October 25, 2011 Share Posted October 25, 2011 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 More sharing options...
Ingolme Posted October 25, 2011 Share Posted October 25, 2011 I think you have to turn the element into a jQuery element for that:$(currentElement).hasClass('is228') Link to comment Share on other sites More sharing options...
Costanza Posted October 25, 2011 Author Share Posted October 25, 2011 I think you have to turn the element into a jQuery element for that:$(currentElement).hasClass('is228')Ah, you're right! Man, this jQuery syntax is going to take some getting used to. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.