javascript - Linking to specific twitter bootstrap tabs from URL on same page -


i'm javascript noob , i'm wondering how implement answer question?

twitter bootstrap tabs: go specific tab on page reload or hyperlink

i want use code on same page tabs located....

  <script type="text/javascript">     // javascript enable link tab     var url = document.location.tostring();     if (url.match('#')) {       $('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;     }       // change hash page-reload     $('.nav-tabs a').on('shown', function (e) {       window.location.hash = e.target.hash;     })   </script> 

where inside page containing tabs should plugg in.

again, sorry being such noob.

try wrapping code in $(document).ready() function

$(document).ready(function() {  //your code here... }); 

what have above won't work dom won't ready when runs. using $(document).ready() function delay execution until dom has loaded. can go pretty anywhere in page containing tabs. people think should go within head section, think should go @ end. read here more in-depth answers on that: where put $(document).ready()?

see: http://docs.jquery.com/tutorials:introducing_$(document).ready()


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -