javascript - Jquery will not hide/show div -


i'm trying hide live chat box on page load , when hyperlink clicked, display chat box after 30 seconds.

anybody have ideas i'm doing wrong?

jquery

<script type="text/javascript">     jquery(document).ready(function ($) {         var thislive = document.getelementbyid('livechat');         $(thislive).hide();          $("#chatbox").click(function () {             var thislive = document.getelementbyid('livechat');             $(thislive).delay(30000).show(); // display after 30 seconds         });     }); </script>  <div id="livechat">     <!-- start of livechat (www.livechatinc.com) code -->     <script type="text/javascript">         window.__lc = window.__lc || {};         window.__lc.license = 111111;         (function () {             var lc = document.createelement('script'); lc.type = 'text/javascript'; lc.async = true;             lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';             var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(lc, s);         })();     </script>     <!-- end of livechat code --> </div> 

cshtml

            <div class="col-sm-3 col-md-3">                 <a id="chatbox" href="#panel-column-3" class="panel-column row-collapse-toggle collapsed" data-toggle="collapse" aria-expanded="false" aria-controls="bpanel-column-3">                     <i class="fa fa-question-circle"></i>                     <h3>@umbraco.field("contactustab3title")</h3>                 </a>                 <div class="row-collapse collapse" id="panel-column-3">                     <div class="inner">                         @umbraco.field("contactustab3content")                     </div>                 </div>             </div> 

update below works. think problem chat script itself. seems when inside div has mind of own.

<script type="text/javascript">     jquery(document).ready(function ($) {     var thislive = document.getelementbyid('livechat');     $(thislive).hide();          $("#chatbox").click(function () {             var thislive = document.getelementbyid('livechat');             $(thislive).delay(5000).show(0); //5 seconds         });     }); </script>  <div id="livechat">     <div>         test     </div> </div> 

you want set timeout here , not delay. this,

 settimeout(function(){ $(thislive).show(); }, 30000); 

so replace

$(thislive).delay(30000).show(); 

final code

<script type="text/javascript">     jquery(document).ready(function ($) {         var thislive = document.getelementbyid('livechat');         $(thislive).hide();          $("#chatbox").click(function () {             var thislive = document.getelementbyid('livechat');              settimeout(function(){ $(thislive).show(); }, 30000); // display after 30 seconds         });     }); </script> 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -