Question: JavaScrpt expert, 

i want if the below script exist in my template coding then my page should redirect to example.com

```
   <script>
   $(document).ready(function(){
        $("#wrapper").hide();
   })
   </script>

```

if the above script exist in my template, then it should redirect to example.com

**Attention:** please add some condition in that script like this: 

```
  <script>
  $(document).ready(function(){

  If   
  //#wrapper is hide

 $("#wrapper").hide();

  //then it should redirected to example.com

  </script>

```

I hope someone will figure out and will share code with me. thanks.

Answer: 
If you need this functionality somewhere after the bit of code you show, this would work:

```
var $wrapper=$("#wrapper");
if($wrapper.length>0 && !$wrapper.is(':visible')){ 
    // #wrapper exists on the page but is not visible,  redirect user
    window.location.href = "http://example.com";
}

```
What Taplar says is:

```
   <script>
   $(document).ready(function(){
        // $("#wrapper").hide();
        window.location.href = "http://example.com";
   })
   </script>

```

If you need this behaviour in another place in your code, then see DelightedD0D answer.

Very good point by DelightedD0D, I've fixed the code. ;)
DelightedD0D, I'd give you another point if I could.