{"id":3027,"date":"2010-04-07T09:53:01","date_gmt":"2010-04-07T09:53:01","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/avoiding-flicker-with-jquery-tabs\/"},"modified":"2016-07-28T10:49:56","modified_gmt":"2016-07-28T10:49:56","slug":"avoiding-flicker-with-jquery-tabs","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/avoiding-flicker-with-jquery-tabs\/","title":{"rendered":"Avoiding Flicker with JQuery Tabs"},"content":{"rendered":"<p>I am a huge fan of JQuery because it seems like every time I want to do something it has a plugin that already does it.&#160; Adding a tabbed interface to a web page was always quite an annoyance, but JQuery UI offers a pretty descent tabs solution (<a href=\"http:\/\/jqueryui.com\/demos\/tabs\/\">click here to see it<\/a>).&#160; If you read through the documentation, you&#8217;ll find that you can create a tabbed interface by calling the <strong>tabs()<\/strong> method on an element containing an unordered list.&#160; The only problem that I&#8217;ve experienced with the method is that on slower machines you can see the unordered list render out in its original state before being updated into the final tabbed interface.&#160; A quick way to fix that issues is to set the CSS display property of the element to none, then call the <strong>show()<\/strong> method directly after calling the <strong>tabs()<\/strong> method.&#160; This keeps the element completely hidden while JQuery sets up the tabs interface and eliminates the flicker.<\/p>\n<p><code>&lt;SCRIPT type=\"text\/javascript\"&gt;      <br \/>&#160;&#160;&#160;&#160; $(function()       <br \/>&#160;&#160;&#160;&#160; <\/code><code>{      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(\"#tabs\").tabs();       <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(\"#tabs\").show();       <br \/>&#160;&#160;&#160;&#160; });       <br \/>&lt;\/SCRIPT&gt;       <\/p>\n<p><\/code><code>&lt;div id=\"quot;tabs\"\" style=\"display:none;\"&gt;     <br \/>&#160;&#160;&#160; &lt;ul&gt;      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;&lt;a href=\"#tabs-1\"&gt;First Tab&lt;\/a&gt;&lt;\/li&gt;      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;&lt;a href=\"#tabs-2\"&gt;Second Tab&lt;\/a&gt;&lt;\/li&gt;      <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;li&gt;&lt;a href=\"#tabs-3\"&gt;Third Tab&lt;\/a&gt;&lt;\/li&gt;      <br \/>&#160;&#160;&#160; &lt;\/ul&gt;      <br \/>&#160;&#160;&#160; ...<\/code><code>     <br \/>&lt;\/div&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am a huge fan of JQuery because it seems like every time I want to do something it has a plugin that already does it.&#160; Adding a tabbed interface to a web page was always quite an annoyance, but JQuery UI offers a pretty descent tabs solution (click here to see it).&#160; If you&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3027","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3027"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3027\/revisions"}],"predecessor-version":[{"id":41875,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3027\/revisions\/41875"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3027"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}