Soldato
- Joined
- 12 Feb 2006
- Posts
- 17,660
- Location
- Surrey
i got a very simple problem which can't seem to find the solution to.
i have an input field that does an ajax search and then slides in the results usin jquery. what i want is if the user clicks on anything but the input field or the results box then slide the box back away.
i thought it would be nice and simple but it appears not, below is the latest thing i have tried.
but it doesn't work
if i alert each var then i get undefined, or if i remove the attr('id') i get object Object.
i have an input field that does an ajax search and then slides in the results usin jquery. what i want is if the user clicks on anything but the input field or the results box then slide the box back away.
i thought it would be nice and simple but it appears not, below is the latest thing i have tried.
Code:
$(document.body).click(function(event) {
var boundary1 = $('#searchInput');
var boundary2 = $('#searchResults');
var clickedEl = $(this).attr('id');
if(clickedEl != boundary1 && clickedEl != boundary2) {
//do the slide
}
});
