Is there a snippet of javascript that could specify to make the div with class "cbUserListFieldLine" invisible if the span with class "cbUserListFC_cb_extdesc" is empty?
Sorry, I'm still very new to hand coding javascript and don't even know where to start with making it do what I want it to. Even a general direction would be helpful.
Firstly, can need to give your elements an "ID", so we can get a reference to them.
So, lets give the span an ID of "mySpan" and the Div and ID of "myDiv", as follows:
Thank you both but I'm still not having any luck...
ilawton: I cannot hack the dynamically created code so adding ids is not an option for me...sorry. :/
mrhoo: Your solution looks like it should work perfectly but has no effect in the page. This is the code after being implemented, did I do something wrong?
I've included the entire head of the document because it dynamically adds quite a bit of javascript, including jquery. Just trying to make sure I don't have a conflict happening. Your code is at the very bottom.
EDIT: Looks like I had the class wrong...It should be if class "cbListFieldCont" is empty then the parent div should be display=none. However, if I change the javascript to accommodate that, it just makes the user pictures disappear, and the empty "Specialty:" fields remain visible....
Yep, you should be looking for only the fields that are Speciality ones... The code from before was fine, but you just needed to look for "cbUserListFC_cb_description" as well as "cbUserListFC_cb_extdesc".
So, the code should be:
Code:
window.onload=function(){
var spans= document.getElementsByTagName('span');
var i= 0, L= spans.length, tem, pa;
while(i<L){
tem= spans[i++];
if((tem.className.indexOf('cbUserListFC_cb_extdesc')!= -1 || tem.className.indexOf('cbUserListFC_cb_description')) && !tem.textContent && !tem.innerText){
tem.parentNode.style.display = "none";
}
}
}
I tested the above and it works good. No Speciality tags!
Also, the following bit of code is throwing a javascript error. So, I'd remove it if I were you.
It looks like this code is working in IE, but in Firefox, the Specialty tags are still there...
...and for some reason in both browsers the javascript is also removing my user pictures and login fields on the left as well as creating some weird display issues with the header. :/
Any ideas what may cause this? Does the "parentNode" include more than just the divs that the spans are in?
There is just one remaining (and rather random) display issue in IE (7, on my computer) where the heading is getting pushed down and covered up by the sub-heading.
:/ Any clue? If not, it's okay...you've been MORE than helpful!
Not sure about the CSS bug. Looks like the div "contentheading cbUserListTitle" needs floating left, or some height set on it. Defo an IE7 vs IE8 CSS issues.
Bookmarks