Attention:

Support Rules and Guidelines
Before you post your support topic, please remember to:
  • Read the support forum rules.
  • Check the wiki and use search to see if your problem can be answered there first.
  • Link your board please, and make sure that the problem on your board is visible to guests or provide a test account.
  • Do not post Board Wrappers and CSS unless requested. With a board link, this is not necessary.
  • Be as descriptive as you can and use as many details as possible when describing your problem.
  • Please briefly mark any links to forums that may not be work-safe.
This will help ensure your support issue will be attended to in a quick and efficient manner.

  Add ReplyNew TopicNew Poll

 Modifying CSS with jQuery of blank custom profile fields
#
Link: https://snowred.jcink.net/index.php?showuser=7

Apologies in advance if it seems a little odd, but I'm trying to fiddle with jQuery to make it so that, if one custom profile field has "No Information" (i.e; user left it blank because it does not apply to them), the adjacent divs for the fields to the left move over.

CODE
<script>$('.creation:contains("No Information")').remove();</script>


This is what I am using to remove the custom profile field (wrapped in a span called "creation") when it is blank. I'd like for the previous two fields, "true-age" and "rank" to move over to the left. I don't know any jQuery, but this is what I wrote:

CODE
$('.true-age').css({
     'position': 'relative',
     'left' : '80px',
});

$('.rank').css({
     'position': 'relative',
     'left' : '90px',
});


CODE
if ($('.creation').is(':empty')) {
     $('.creation').remove();
}


I'd like it to be coded so that IF the creation field is blank, it's removed AND "true-age" and "rank" move over 80 and 90px to the left respectively. These statements would only apply if the field is blank: if it's filled, then the statements do not apply.

I hope I'm making sense here. jQuery is not my area of expertise, so I'm not sure how to proceed forward, but I am sure this can be done ... albeit in a tricky way. Thanks in advance.

signature
And I stood upon the sand of the sea, and saw a beast rise up out of the sea, having seven heads and ten horns, and upon his horns ten crowns, and upon his heads the name of blasphemy. - Revelation 13:1-18

blood red. snow white.
PM
#
If I'm understanding what you're trying to achieve correctly, try this:
CODE
<script>$('.creation:contains("No Information")').remove();</script>

Change that to this:

CODE
<script>
$('.creation:contains("No Information")').parent('td').remove();

if ($('span.true-age').parent('td').parent('tr').find('td').length === 2) {
   $('td:has(span.true-age)').before('<td></td>');
}
</script>

signature
user posted image
#
Hey Cory, thanks for responding. Your code definitely works, but it pushes the previous two elements to the far right when I would like them to be a bit more centered. This is why I opted to adjust them with CSS in jQuery so that they would be center-aligned, rather than moving over to the far right.

Let me know if a visual would better help explain.

signature
And I stood upon the sand of the sea, and saw a beast rise up out of the sea, having seven heads and ten horns, and upon his horns ten crowns, and upon his heads the name of blasphemy. - Revelation 13:1-18

blood red. snow white.
PM
#
Try this instead:

CODE
<script>
$('.creation:contains("No Information")').parent('td').remove();

if ($('span.true-age').parent('td').parent('tr').find('td').length === 2) {
   $('.true-age').css({
       'position': 'relative',
       'left': '80px',
   });

   $('.rank').css({
       'position': 'relative',
       'left': '90px',
   });
}
</script>

signature
user posted image
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Share this topic:
« Next Oldest | General Support | Next Newest »

Options Add ReplyNew TopicNew Poll