Home › Forums › JavaScript › How to hide parent div if custom_field is empty
- This topic is empty.
-
AuthorPosts
-
February 12, 2013 at 5:39 pm #42683
MadaHo
MemberHi guys,
I am not familiar with js or jquery but I need that to finish my “work”. I want to hide parent div bubble if value of, let say, custom_field (**CC_STAUS**) is empty.
Below code is only a part of the rest:
CC_STATUSand css
.bubble {
overflow:hidden;
margin:5px 0 0 0;
}
.bubble .speach {
background-color:#333333;
color:#FFFFFF;
padding:5px;
margin:0;
font-size: 12px;
font-family: Segoe UI;
text-transform: lowercase;
}
.bubble .arrow {
margin:0 0 0 15px;
width:0;
height:0;
border-left: 0px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #333333;
border-top: 0;
}To check the lenght of the **CC_STATUS** I have tried this code (which I simply adapted) but obviously it does not work. The bubble is always displaied no matter of it content.
$(‘.bubble’).each(function() {
if($(this).attr(‘CC_STATUS’) === ” || $(this).text() === ”) {
$(this).parents(‘.bubble’).hide();
}
});See [jsfiddle](http://jsfiddle.net/9QayV/1/ “jsfiddle”)
Thanks in advance for any (working) solution.
February 12, 2013 at 6:03 pm #123771CrocoDillon
ParticipantFebruary 12, 2013 at 6:13 pm #124306MadaHo
MemberNo, it must be the same as my code, CC_STATUS is a tag that trigger value from external server.
Your code is showing one bubble with text and another one below without text.
I need to find something that will check walue of CC_STATUS tag and then hide div.bubble if this value is empty.February 12, 2013 at 6:49 pm #124313chrisburton
ParticipantWhy wouldn’t you just use PHP for this?
February 12, 2013 at 7:29 pm #124318MadaHo
MemberHm… I’m creating template for instant messenger and **CC_STATUS** is used to get user description which I can display on contact list. So this tag, as many other like i.e. USER_NAME must be inserted in HTML code (not PHP) of the template.
SO CC_STATUS is just constant element of the template. Is it possible that I could check with jquery that this tag has any value?February 13, 2013 at 3:32 am #124362Derek Wood
Participantnevermind
February 13, 2013 at 6:38 am #124399MadaHo
MemberIM (like Miranda or Trilian) is a program (so no live website) that is skinned almost the same way as HTML website. It is using IE engin to render themplate.
To get some information about users we need to use some special tags – like CC_STATUS (for statuses), CC_NAME (for nicknames), CC_AVATAR (for avatars). There is a lot of other tags without template will not work. It looks probably the same as we creating website with PHP (in this case all information we take from database).
Below is example of code displaing user table on contact listCC_USER_AVATARCC_JID_PREFIXCC_STATUSincluding that part I am talkin about.
I know that it is possible to write script that would check if CC_STATUS has any value – I mean if user in theyr messenger set any status (it can be just text, digit or url link or contain both).
February 13, 2013 at 7:20 pm #124510MadaHo
MemberYes, I have… And te result is:
http://i47.tinypic.com/2ppkfm8.jpg
I would like to get this (but without empty bubble if CC_STATUS has no value)
http://i46.tinypic.com/2uyrggh.jpg
And your code could look like this http://codepen.io/MadaHo/pen/GHAIa
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.