jquery - Javascript hide element (when clicked outside) with certain conditions -


so there questions here hiding div when clicking outside of it. have 1 thing, there div(accounts-edit-table-name-edit) showing hidden div(account-edit-group) on click first. , - if click somewhere else out of div(account-edit-group) - must hide. here code trying 2 different conditions (or):

$(document).click(function(event) {         if($(event.target).parents().index($('.account-edit-group')) == -1 || $(event.target).parents().index($('.accounts-edit-table-name-edit')) == -1)             {                    if($('.account-edit-group').is(":visible"))                      {                     $('.account-edit-group').removeclass('acc-edit-f');                         alert("hiding")                     }             }             }); 

html:

<div class="accounts-edit-table-name-edit">"button"</div> <div class="account-edit-group">block</div> 

(class "acc-edit-f" contains "display: block")

well, if click on div class "accounts-edit-table-name-edit" - system show me alert("hiding") though must through conditions , ignore that. there ways fix this?

see jsfiddle if want :

http://jsfiddle.net/5e6c6/2/

 $(event.target).parents().index($('.account-edit-group')) //always return -1  $(event.target).parents().index($('.accounts-edit-table-name-edit')) // 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -