Ad

Load Jquery Function Before Content

- 1 answer

i made this function:

var jq111 = jQuery.noConflict();

if (jq111("#tab-upsell_tab").find("div").length > 0){ 

} else {

    jq111(".upsell_tab_tab").hide();
    jq111("#tab-upsell_tab").hide();

}

This hide a element if are empty.

But on page load, #tab-upsell_tab appear for 1 second (if need to be hide) and i don't like it.

There is a way to load this function before this element? Or something similiar.

Edit: i accept a css solution, but how?

Ad

Answer

You should set .upsell_tab_tab and #tab-upsell_tab to display: none in your CSS. Change your JavaScript to this also:

var jq111 = jQuery.noConflict();

if (jq111("#tab-upsell_tab").find("div").length > 0){ 

  jq111(".upsell_tab_tab").show();
  jq111("#tab-upsell_tab").show();

}

This way your elements are hidden by default, and you must imperatively show them based on your logic.

Ad
source: stackoverflow.com
Ad