Mask the item if it is empty
2 posters
Page 1 of 1
Mask the item if it is empty
Hi to all of you,
Ange Tuteur if you pass by here
I want to hide this item ( sous_forum_s and ouverture_sousforum_s ) if it is empty,
the effect is for the sub forums.
Here is the HTML code
- Code:
<div align="left" class="sous_forum_s">
<span class="sforum_s">
<span>
{catrow.forumrow.L_LINKS}{catrow.forumrow.LINKS}
{forumrow.L_SUBFORUM_STR} {forumrow.SUBFORUMS}
</span>
</span>
<span class="ouverture_sousforum_s">◄</span></div>
</div>
thank you in advance .
a++
Re: Mask the item if it is empty
Hi @Milouze14,
You want to hide the element when there are no sub-links, correct ?
If so, this JavaScript should do the trick :
Modules > JS codes management > New
Placement : In the homepage
In some instances you can also use the CSS
pseudo-selector(link), however I don't think that would be applicable here.
You want to hide the element when there are no sub-links, correct ?
If so, this JavaScript should do the trick :
Modules > JS codes management > New
Placement : In the homepage
- Code:
$(function() {
for (var a = $('.sous_forum_s'), i = 0, j = a.length; i < j; i++) {
if (!a[i].getElementsByTagName('A')[0]) {
a[i].style.display = 'none';
}
}
});
In some instances you can also use the CSS
|
Re: Mask the item if it is empty
Grrr, it's been two hours that I get tired and you in a few seconds, you released me .
Yes I tested with CSS selector, but nothing concrete.
Thank you a lot
a++
Yes I tested with CSS selector, but nothing concrete.
Thank you a lot
a++
Re: Mask the item if it is empty
You're welcome ^^
Yes, the
selector is pretty useless on the forums, so it's better to go with JavaScript. With JS you just need to loop the elements to see if they have the children you want. Here's the same code, but entirely in jQuery :
refers to the amount of <a> elements ( or sub-links ) that
contains. If it's equal to 0, we hide the element.
Yes, the
|
- Code:
$(function() {
$('.sous_forum_s').each(function() {
if ($('a', this).length == 0) {
$(this).hide();
}
});
});
|
|
Re: Mask the item if it is empty
Oh thank you for these explanations as being self-taught in this area, I still have just learned something real good, thank you for the time you spend to help people like me
thank you again Ange Tuteur .
a++
Re: Mask the item if it is empty
No problem, if you have any questions you can always ask me.
Topic archived
Have a great day.
Topic archived
Have a great day.
Similar topics
» Profile/Item Question
» Scroll down item fall script?
» Empty CSS Template
» empty rectangle
» CSS Sheet is empty
» Scroll down item fall script?
» Empty CSS Template
» empty rectangle
» CSS Sheet is empty
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum