I have an image that has an InnerHTML for "a href" tag define in the .cs file as shown below.如何隱藏<a href> tag in InnerHTML
_divToolTipContainer.InnerHtml = "<a href=\"javascript:__doPostBack('" + btnItemThumbnail.ClientID.Replace("_", "$") + "','')\">" +
itemimage;
Now what I want is to have this "a href" tag "hide" or "set visible to false" if the textbox is empty otherwise have this click-able.
My code is shown below, but its not working.
var oDivA1 = document.getElementById(oElementId);
if(val === undefined || val == null || val.length <= 0){
oDivA1.style.display = "none"; // not working
}else{
oDivA1.style.display = "block"; // not working
}
oDivA1.style.display = "none", this display none for the entire div not the "a href" tag only.
Is that possible?
Thanks
RJ
您至少沒有關閉您的錨標記,也沒有關閉您顯示的代碼。 – tvanfosson
'innerHTML' javascript方法不應該大寫,但'HTML'這個詞需要大寫。 –