There are div elements with the placeholder class, each has a data-price with a value, for this value you need to leave everything that is more than 30,000 and less than 40,000.

$(".placeholder").data('price') //*Выдаёт значение price с первого div* 

You can delete \ hide all that is more than 30,000 and less than 40,000 through the function by the value of .data('price') , but I don’t get it right :(

    2 answers 2

    I am a fan of pure JavaScript . Therefore, suddenly come in handy.

     var items = document.querySelectorAll(".placeholder"); for (var i = 0; i < items.length; i++) { var data_info = +items[i].dataset.price; if (data_info > 30000 && data_info < 40000) items[i].style.display="none"; } 
     <div class="placeholder" data-price="33000">33000</div> <div class="placeholder" data-price="20000">20000</div> <div class="placeholder" data-price="45000">45000</div> <div class="placeholder" data-price="35000">35000</div> 

    • the question is not just a jquery label :) well, and it was possible to get by without the second cycle - Grundy
    • @Grundy, so yes. I'll just leave my answer here) - Amandi
    • @Regent, yes, my joint, I admit) - Amandi
    • @ Artyom about the purity of JS remains, but this is painfully delicate matter, to which the majority does not care. In principle, the non-jQuery option in this case looks competitive. - Regent
    • @Regent, "Clean" I meant - without using JQuery (I don't like it) - Amandi

    Here you need to use the filter function and leave only those that need to be removed / hidden.

     var items = $(".placeholder").filter(function(index, el){ var price = +$(el).data('price'); // получаем цену элемента return price > 30000 && price < 40000; //оставляем его в наборе при следующих условиях }); items.remove();// удалить все выбранные; items.hide();// скрыть все выбранные; 
    • "you need to leave everything that is more than 30,000 and less than 40,000" and "You can delete / hide everything that is more than 30,000 and less than 40,000" - this is, in my opinion, great. And why did you decide to stop at the option with “can”, and not with “need”? - Regent
    • @Regent, I decided to leave - this is the type in the filtered collection, and then left to remove these :-) But in principle, any option is obtained by replacing the condition, I hope the author will figure it out :-) - Grundy
    • Yes, it may have such a meaning behind these words and lies :) - Regent