I have li.box, li.car which are inside a $(this) which contain modified values and then I have box_orig, car_orig containing the original lists…
how can I replace $(this)‘s data (html data, the li’s content) with the original list, so if $(this) contains li.box then I need to replace it with box_orig‘s data
Edit:
var list = $("ul#list");
var box_orig = list.children('.box');
var car_orig = list.children('.car');
And $(this)
$('#list li').each(function () {
if ($.inArray($(this).attr('class'), show) == 0) {
console.log($(this)); //-> Returns li.box / car or whatever list was selected
}
});
Re-edit:
Re-Re-edit:
I realized that replacing the data breaks anything, so replacing goes out of the question, just show car/box_orig instead li.car/box
$('#list li').each(
function(){
//alert($.inArray($(this).attr('class'),show) );
if ($.inArray($(this).attr('class'),show) == 0)
{
if($(this).attr('class') == 'box')
{
--> show box_orig, which contains lis with info BUT DO NOT REPLACE THE DATA, just show the box_orig instead of $(this) = li.box
}
if($(this).attr('class') == 'car')
{
--> show car_orig, which contains lis with info BUT DO NOT REPLACE THE DATA, just show the box_orig instead of $(this) = li.car
}
console.log($(this));
}
html:
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
jQuery(li.car) result...rifting (line 703)
and each li.car contains data (img and text)
Solution: