javascript - Moving items between two list but filtering ones that already exists -


I have a web page that includes two lists (Unidar's lists), I have to move from list 1 to list 2 , But to filter those items that are already in the list 2. I am using the JQuery JS library. I know I can select all the items to move to List 2, loop one by one and checking whether Eldy is present in List 2, but was wandering, if using the filter code There is no way to do this in the lower lines, so no: ... there is an html structure:

    

I first used an array of elements of my list 2 using the inner text , And then using list1 , selecting non-existing elements of list2 using $ .inArray:

 < Code> var list2Items = $ ('# UlList_2 li & gt; a'). Map (function () {return $ (this) .text ();}); // list2Items will be: ["item 2", "item 3", "item 4"] var itemsNotInList2 = $ ('# ulList_1 li & gt; a'). Filters (function () {return $ .inArray ($ (this) .text (), list2Items) == -1; // only select non-existent}); // items  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -