Luey
asked on
jquery compare last-child to variable
All of this code works until i get to my if statement. I am trying to hide a "Next" button when the last element in a div is reached. It all works except the last part.
Thanks
Thanks
$("#test").children().css('display', 'none');
$("#test img:first-child").css('display', 'block');
var currentElement = $("#test img:first-child")
var lastElement = $("#test img:last-child")
function rightNextImage() {
$(currentElement).css('display', 'none').next().css('display', 'block');
currentElement = currentElement.next();
if (currentElement == lastElement) {
$("#right_next").hide();
alert("hello");
}
}
ASKER
tried it could not make it work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
currentElement.is( lastElement )