2014-07-15 39 views
0

我试图找出如何隐藏我的一个侧面的导航按钮,如果没有内容加载垂直标签内容PHP数组

(每节1-4每个标签的部分变化身体部分,目前有三个标签加载)

我正在使用一个PHP数组来加载我的网页的这个部分的所有内容。

下面是我的一些代码示例(精简尽我所能) Js Fiddle

我首先想到的是“如果”做的,和“其他”声明,我从另一个例子尝试从这里,但我仍然需要找出一种方法来关闭按钮的CSS只是不确定如何解决这个问题!

任何帮助表示赞赏,请注意我是新手到PHP!

另外这里的部分内容加载与阵列多么正义,帮助直观的链接:

http://imgur.com/WRkXzv3 Screenshot of Array Content

这里是一个真实被列入到PHP文件我的数组的一个片段

// #Hips# 
$injuries['Hips'] = array(
    "BodyPartLink" => "Hips", 
    "TitlePage" => "Hips Injuries & Education", 
    "IntroTxt" => "Hips Intro Text Here", 
    "SectionTab1" => "", 
    "SectionTab2" => "Hip Condition #2", 
    "SectionTab3" => "Hip Condition #3", 
    "ContentSection" => "Hips Dummy Text Here For Large Text Section" 
); 

// #Hips Section Contents TAB 1 # 
$Tab1SectionContents['Hips'] = array(
    "Definition" => "<span class='edu-sub-category-txt-bold'>Definition:</span>Lower Back Information coming soon! ", 
    "Function" => "<span class='edu-sub-category-txt-bold'>Function:</span>Information coming soon!", 
    "Mechanism" => "Mechanism of Injury ", 
    "MechanismTxt" => "Information coming soon!", 
    "Sign-Symptoms" => "Signs & Symptoms ", 
    "Sign-SymptomsTxt" => "Information coming soon!", 
    "Etiology" => "Etiology ", 
    "EtiologyTxt" => "Information coming soon!", 
    "Pero-Treatment" => "Pero Treatment ", 
    "Pero-TreatmentTxt" => "Information coming soon!", 
    "Other-Treatment" => "Other Treatment ", 
    "Other-TreatmentTxt" => "Information coming soon!" 
); 

// #Hips Section Contents TAB 2 # 
$Tab2SectionContents['Hips'] = array(
    "Definition" => "<span class='edu-sub-category-txt-bold'>Definition:</span>Lower Back -- Phasellus erat sem, molestie vitae turpis et, vehicula facilisis dolor. Mauris ut iaculis eros,  in auctor nibh. In eget nisl tristique elit varius semper. ", 
    "Function" => "<span class='edu-sub-category-txt-bold'>Function:</span> Function -- molestie vitae turpis et, vehicula facilisis dolor. Mauris ut iaculis eros,", 
    "Mechanism" => "Mechanism of Injury ", 
    "MechanismTxt" => "Text for Mechanism", 
    "Sign-Symptoms" => "Signs & Symptoms ", 
    "Sign-SymptomsTxt" => "Signs & Symptoms ", 
    "Etiology" => "Etiology ", 
    "EtiologyTxt" => "Etiology ", 
    "Pero-Treatment" => "Pero Treatment ", 
    "Pero-TreatmentTxt" => "Pero Treatment ", 
    "Other-Treatment" => "Other Treatment ", 
    "Other-TreatmentTxt" => "Other Treatment " 
); 

// #Hips Section Contents TAB 3 # 
$Tab3SectionContents['Hips'] = array(
    "Definition" => "<span class='edu-sub-category-txt-bold'>Definition:</span>Lower Back -- Phasellus erat sem, molestie vitae turpis et, vehicula facilisis dolor. Mauris ut iaculis eros,  in auctor nibh. In eget nisl tristique elit varius semper. ", 
    "Function" => "<span class='edu-sub-category-txt-bold'>Function:</span> Function -- molestie vitae turpis et, vehicula facilisis dolor. Mauris ut iaculis eros,", 
    "Mechanism" => "Mechanism of Injury ", 
    "MechanismTxt" => "Text for Mechanism", 
    "Sign-Symptoms" => "Signs & Symptoms ", 
    "Sign-SymptomsTxt" => "Signs & Symptoms ", 
    "Etiology" => "Etiology ", 
    "EtiologyTxt" => "Etiology ", 
    "Pero-Treatment" => "Pero Treatment ", 
    "Pero-TreatmentTxt" => "Pero Treatment ", 
    "Other-Treatment" => "Other Treatment ", 
    "Other-TreatmentTxt" => "Other Treatment " 
); // ## END HIPS ## 

回答

0

你可以用Javascript来做到这一点。检查与您的标签关联的div是否为空 - 因此没有数据/内容出现。如果它是空的,请将其移除。

$(function(){ 
    if (!$('.element').html()){ 
     // If the element is empty, remove it 
     $('.element').remove(); 
    } 
}); 
+0

好,谢谢,我会尝试给一个去 – dimerbox

+0

请注明我的问题是正确的,如果你的作品(和+1吧)。谢谢=) – Ben

+0

哦,好吧,一旦我有机会,我一定会这么做!非常感谢这个网站! :) – dimerbox