Scenariusz to mam dwa div
s: jeden jest tam, gdzie wybieram pozycje (divResults
) i przechodzi do następnego div (divSelectedContacts
). Kiedy go wybieram, umieszczam obok niego znacznik wyboru. Co chcę zrobić, gdy wybiorę go ponownie, chcę usunąć zaznaczenie, a także usunąć element z divSelectedContacts
.
Oto kod:
$("#divResults li").click(function()
{
if ($(this).find('span').size() == 1)
{
var copyElement = $(this).children().clone();
$(this).children().prepend("<span class='ui-icon ui-icon-check checked' style='float:left'></span>");
$("#divSelectedContacts").append(copyElement);
} else
{
var deleteElement = $(this).find('span'); //here is the problem how to find the first span and delete it
$(deleteElement).remove();
var copyElement = $(this).children().clone();//get the child element
$("#divSelectedContacts").find(copyElement).remove(); //remove that element by finding it
}
});
nie wiem jak wybrać pierwszą span
w li
użyciu $(this)
. Każda pomoc jest doceniana.
Dziękuję bardzo :-). Element deleteElement nie wystąpił mi. Dobry połów. – Raja