Selecting all elements whose parents don't have a certain class (using '.not()')
Date : March 29 2020, 07:55 AM
will be helpful for those in need You'll need to check for parent elements, and closest() stops at the first element found with that class, and if the selector has length, ie. contains elements, there is an element somewhere up the DOM tree with that class. $('.select').filter(function(){
return !$(this).closest('.forbidden').length;
});
|
jQuery - Selecting children by class using parents ID
Date : March 29 2020, 07:55 AM
help you fix your problem To append to your first scrollbar locate it by the id #mCSB_1 and use the child selector > to get to your desired container, like so: $('#mCSB_1 > .mCSB_container').append('<li class="product-tree"> New LI </li>');
$('#mCSB_2 > .mCSB_container').append('<li class="product-tree"> New LI </li>');
|
jQuery selection of element based on class; but only selecting top most parents
Date : March 29 2020, 07:55 AM
around this issue The following selects all .ui-selected elements, then filter()s them, to only give you those which are "top level" (i.e. don't have any ancestors which are .ui-selected.) ... I think that's what you wanted, at least. $('.ui-selected').filter(function () {
return !$(this).parents('.ui-selected').length;
});
$('.ui-selected').filter(function () {
return !$(this).parents('.ui-selected').length;
}).on('click', function () {
alert("Hi, I'm a top-most .ui-selected, and you just clicked me!");
});
|
How to hide parents of a specific child-class
Date : March 29 2020, 07:55 AM
wish of those help I want to hide parents of an element with the class ".close" when clicking. In details: If a user clicks on an element with the class "close" I want the parent-container of the clicked element to be hidden. , Your code should look like this: $(".close").click(function(e) { //check selector
$(this).parent().addClass("hide"); //parent() is a function
location.hash = "#hidden";
});
|
MySQL: selecting joined rows, where children don't belong to a specific parents id
Date : March 29 2020, 07:55 AM
around this issue The question might sound a little confusing, I'll do my best to explain it. I have 4 tables: SELECT store_item_stock.id, store_item_stock.id_attribute, store_item_stock.stock
FROM store_item_stock
JOIN store_cat_attribute
ON store_item_stock.id_attribute=store_cat_attribute.id_attribute
WHERE id_cat NOT IN (
SELECT store_item.id_cat
FROM store_item JOIN store_cat_attribute
ON store_item.id_cat=store_cat_attribute.id_cat
WHERE store_item.id_cat=2
GROUP BY store_item.id_cat);
|