In $('body').not('#x') you are asking for all 'body' tags which don't
have the 'x' ID. That gives you zero elements. The second example is
closer, but .not() doesn't support complex selectors.
$('a').filter(function(){
return !$(this).parents('#x').length;
});
docs.jquery.com/Traversing/filter
- ricardo
On Dec 18, 1:11 pm, elubin <[email protected]> wrote:
> How do i select all of the anchor links that are NOT in the div x?
>
> <body>
> <a href="" onclick="alert('TODO');return false;">outide div 1</a>
> <div id="x">
> <div><a href="" onclick="alert('TODO');return false;">inside div 1</
> a></div>
> <a href="" onclick="alert('TODO');return false;">inside div 2</a>
> <a href="" onclick="alert('TODO');return false;">inside div 3</a>
> </div>
> <a href="" onclick="alert('TODO');return false;">outide div 2</a>
> <a href="" onclick="alert('TODO');return false;">outide div 3</a>
> </body>
>
> // this doesn't work
> $('body').not('#x').find('a').click(.......
> // this doesn't work
> $('a').not('#x a').click(.......