Question: When I use hide and confirm in html. The hide is not working properly in Chrome only. When the confirmation window is shown, the "aa" element is not hidden. IE and FF is working fine.  

Any kind of suggestion is appreciated.

```
<html>
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
</head>
<body>
    <a id='aa' href='javascript:hideit();'>try it</a>
    <script type='text/javascript'>
        function hideit() {
            $('#aa').hide();
            if (!confirm('hide?')) {
                $('#aa').show();
                return;
            }
            $('#aa').show();
        }
    </script>
</body>
</html>

```

Answer: 
The hide function is actually working normally. The confirm dialog is the cause of the issue.

The issue occurred because after calling the hide function (while the browser is repainting itself to hide the element), the confirm dialog is triggered immediately which stops everything till it gets response. Hence, the hide function didn't run completely until after the confirm dialog.

**Solution:**
The jQuery hide function takes a callback function [see doc](https://api.jquery.com/hide/#hide-duration-easing-complete). So we would call the confirm dialog only after the element is hidden.

```
.hide( duration [, easing ] [, complete ] ) 
// Default duration = 400, easing = swing

```

*Your can pass a duration of 100 if you want it to hide fast though*

```
<html>
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
</head>
<body>
    <a id='aa' href='javascript:hideit();'>try it</a>
    <script type='text/javascript'>
        function hideit() {
            $('#aa').hide(100, function () {
                if (!confirm('hide?')) {
                    $('#aa').show();
                    return;
                }
                $('#aa').show();
            });
        }
    </script>
</body>
</html>

```
Please check following code, it works properly in all browsers :

```
 <html>
 <head>
 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" >
 </script>
 </head>
 <body>
      <a id='aa' href='javascript:hideit();'>try it</a>
      <script type='text/javascript'>
           function hideit() {           
               if (confirm('hide?')) {
                 $('#aa').hide();                
               }
              else
              {
                $('#aa').show();
              }
           }
     </script>
</body>
</html>

```

Thanks...