Writing a jQuery function to test the class of a <td> and act accordingly. The function works by clicking the img inside the <td> and uses the class information of the td to test.
$(document).ready(function () { $('td img').click(function () { if ((this).parent().hasClass('x')) { alert("Seat " + ((this).parent().attr("id")) + " is taken"); } else if ((this).parent().hasClass('selected')){ $(this).attr('src', 'images/a.gif'); $(this).parent().removeClass('selected'); alert($(this).parent().attr("class")); return false; } else { $(this).attr('src', 'images/c.gif'); $(this).parent().addClass('selected'); alert($(this).parent().attr("class")); return false; }; }); }); The error says that the method for the image does not exist, despite me specifying the parent.