Извинявам се за объркания скрипт и етикети, просто съм начинаещ. Искам да избера текста в div с класа "reserveAPickupAppointmentLocation. Този div е вътре в $(this). $(this) е избраният запис от многото. Релевантният ред е:
var location = $(".reserveAPickupAppointmentLocation, this").text();
Това връща местоположението от всички записи, вместо само от $(this). Как да получа само това, което искам?
Пълна jquery функция:
$(".reserveAPickupAppointmentRoommateAppointment").click (function() {
if ($(this).hasClass("confirm")) {
}
else {
$("img").remove(".confirmAppointment");
$(".reserveAPickupAppointmentRoommateAppointment").removeClass("confirm");
$(this).addClass("confirm");
$(this).append("<img src=images/confirmAppointment.png class=confirmAppointment id=roommateAppointment>");
$(".confirmAppointment").click (function() {
$(".confirmAppointment").unbind("click");
var location = $(".reserveAPickupAppointmentLocation, this").text();
alert (location);
});
}
});
съответната php част
echo '<table>';
while ($row = mysql_fetch_array($result)) {
echo
'<tbody class = "reserveAPickupAppointmentRoommateAppointment">
<tr>
<td>'
.$row["name"].
'</td>
<td>
<span class = "reserveAPickupAppointmentLocation">'
.$row["location"].
'</span>
</td>
<td>
<span class = "reserveAPickupAppointmentSubLocation">'
.$row["subLocation"].
'</span>
</td>
</tr>
<tr>
<td>
<span class = "reserveAPickupAppointmentStartTime">'
.$row["startTime"].
'</span> -
<span class = "reserveAPickupAppointmentEndTime">'
.$row["endTime"].
'</span>
</td>
<td>
<span class = "reserveAPickupAppointmentDate">'
.$row["date"].
'</span>
</td>
</tr>
</tbody>';
}
echo '</table>