unemployment Posted June 3, 2011 Share Posted June 3, 2011 How can I say... If I don't click on this div, do this.... Quote Link to comment https://forums.phpfreaks.com/topic/238336-if-i-dont-click/ Share on other sites More sharing options...
fugix Posted June 3, 2011 Share Posted June 3, 2011 can you explain a little more in depth what is it that you are trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1224827 Share on other sites More sharing options...
unemployment Posted June 3, 2011 Author Share Posted June 3, 2011 can you explain a little more in depth what is it that you are trying to do? I have an autosuggest drop down and when I click it, my onblur from my input field remove my autosuggest box with... search_field.onblur = function() { general_search.hide(); } But if I click a suggested item in the drop down I don't want the onblur to be executed. Any idea how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1224828 Share on other sites More sharing options...
fugix Posted June 3, 2011 Share Posted June 3, 2011 what is supposed to happen when you click on one of the suggestions? im assuming that it doesnt go to a new page Quote Link to comment https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1224843 Share on other sites More sharing options...
Adam Posted June 4, 2011 Share Posted June 4, 2011 Judging by the hide() call I'm guessing you're using jQuery? Hopefully so, as the has() method makes this real easy. Give this a try: search_field.onblur = function() { var curr_target = null; var autosuggest = $('#id_of_autosuggest_box'); if (event.toElement) { curr_target = event.toElement; } else if (event.relatedTarget) { curr_target = event.relatedTarget; } if ($(this).has(curr_target).length == 0 && autosuggest.has(curr_target).length == 0) { general_search.hide(); } } Make sure you change the ID. Quote Link to comment https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1225165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.