Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:36:09+00:00 2026-06-09T03:36:09+00:00

Hi hope someone can help out with this one: What I basically want is

  • 0

Hi hope someone can help out with this one:

What I basically want is that when div introtext is empty it has to hide the div and change the parent div (grid-6) to class=grid-12. I can’t seem to get this job done! Here’s what I have (samplecode):

HTML

<div class=header>
    <img src="[[DTIMAGE]]" alt="inuit.css logo">
</div>
<h1 style="font-size:10px;">[[TITLE]]</h1>
<div class=grids>
    <div class=grid-12>
        [[FULLTEXT]]
    </div><!-- /grid-6 -->
</div><!-- /grids -->
<hr>
<div class=grids>
    <div class=grid-6>
        [[FULLTEXT]]
    </div><!-- /grid-6 -->
    <div class=grid-6>
        <div class="introtext"></div>
    </div><!-- /grid-6 -->
</div><!-- /grids -->
<hr>
<div class=footer>
    [[FOOTER]]
</div>

Script [using jQuery 1.7.2]

$(document).ready(function(){
    if ($(".introtext").text() === ""){
        $(".introtext").hide();
    }
});

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:36:11+00:00Added an answer on June 9, 2026 at 3:36 am

    If I understand correctly, then I’d suggest:

    $('.introtext').each(
        function() {
            if (!$(this).text()) {
                $(this).hide().parent().toggleClass('grid-6 grid-12');
            }
        });​
    

    JS Fiddle demo.

    The above code reworked to account for changes to the requirements, as noted in the comment from the OP:

    I’m totally wrong (too much digging to get this to work) The fact is that if div introtext is empty the div grid-6 (where the [[FULLTEXT]] is in ) should change to div=grid-12

    $('.introtext').each(
        function() {
            if (!$(this).text()) {
                $(this).hide().parent().prev().toggleClass('grid-6 grid-12');
            }
        });​
    

    JS Fiddle demo.

    Reprised the above:

    $('.grid-6').filter(
        function(){
            var introtextEl = $(this).next('.grid-6').find('.introtext');
            return introtextEl.length && !introtextEl.text()
        }).toggleClass('grid-6 grid-12');
    

    JS Fiddle demo.

    The above code (the latest code block), effectively looks at all the elements returned by the selector, and filters them based on two conditions, first: if there is a following element of class grid-6 with a child element of class introtext (jQuery selectors always return an array, hence the .length check), and second: if that found .introtext element has no text-content.

    If these conditions are both true then the currently-assessed element (and all elements for which the conditions are true) are returned to be acted upon by the toggleClass() method.

    References:

    • each().
    • filter().
    • find().
    • hide().
    • next().
    • parent().
    • prev().
    • text().
    • toggleClass().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone can help me out with this one ! I have a sql
Hope someone can help me out with this problem I am having. I just
my SQL skills aren't strong enough to figure this out, hope someone can help.
Hi i hope someone can help. i want to hide the fragment identifier from
I hope someone can help. I have a link like this: <a id='testOne' onclick=doTest('one');
I hope someone can help me with this one, I suspect I am doing
I'm almost losing it, i really hope someone can help me out! I'm using
Hope someone can help i cant seem to get my head around this, i
I hope someone can help me here. I'm having trouble loading this variable. Right
I hope someone can help me with this, as I'm unable to find the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.