I am searching for a method to choose all elements except for one specific element and its descendant, which may contain various levels of children/grandchildren or more. What I'm trying to accomplish is something like...
$("*").not(".foo, .foo *").bind("touchmove",function(e){
e.preventDefault();
});
This code snippet would prevent the touchmove
event on all elements except those with the foo
class and its child elements. However, the complexity arises from not knowing how many levels deep these descendants go, as this piece of code will be utilized across multiple template files that vary in hierarchy depth.
Is there a more efficient way to achieve this? Perhaps an alternative solution besides creating new div/span elements to wrap everything else but the undesired selection (which could take quite some time for unknown reasons).
Any advice or suggestions are warmly welcomed.