परिदृश्य मेरे पास दो div
एस है: एक वह जगह है जहां मैं आइटम (divResults
) का चयन करता हूं और यह अगले div (divSelectedContacts
) पर जाता है। जब मैं इसे चुनता हूं तो मैं इसके आगे एक टिक चिह्न डालता हूं। मैं क्या करना चाहता हूं जब मैं इसे फिर से चुनूं, तो मैं टिक मार्क को हटाना चाहता हूं और divSelectedContacts
से तत्व को भी हटा सकता हूं।
$("#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
}
});
मैं $(this)
का उपयोग कर पहली span
एक li
में चयन करने के लिए पता नहीं कैसे:
यहाँ कोड है। किसी भी प्रकार की मदद की बेहद सराहना की जाती है।
$(this).find(":first-child");
धन्यवाद इतना :-)। DeleteElement मेरे लिए नहीं हुआ था। अच्छी पकड़। – Raja