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

  • SEARCH
  • Home
  • 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 9187983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:54:20+00:00 2026-06-17T19:54:20+00:00

I have the following content… <div class=sectionA></div> <div class=sectionA></div> <div class=sectionA></div> <div class=sectionA></div> First,

  • 0

I have the following content…

              <div class="sectionA"></div>
              <div class="sectionA"></div>
              <div class="sectionA"></div>
              <div class="sectionA"></div>

First, I need to append content to the first empty div…. So I attempted this:

              if(".sectionA").is(":empty"))
              {
                   alert("empty div")
                   $(this).append(value);
              }else // if no available empty divs then insert after last div
              {
                   $(".sectionA:last").after("<div>"+value+"</div>");
              }

This logic is not working and the alert(“empty div”) test never gets trigger and I know there are empty divs as verified through Firebug.. Any idea what I’m doing wrong here?

  • 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-17T19:54:22+00:00Added an answer on June 17, 2026 at 7:54 pm

    You have a syntax error:

    if ( $(".sectionA").is(":empty") )
    // ^ ^ You're missing the parentheses & dollar sign.
    

    However, your logic is flawed. Use this instead:

    var $sections = $(".sectionA");
    var $empty = $sections.filter(':empty');
    
    if ( $empty.length ) {
        $empty.first().append(value);
    } else {
        $sections.last().after('<div>' + value + '</div>');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So let's say have the following content structure: <div class=wrapper> <div class=contentOne style=width:50px></div> <div
I have the following html tree : <div class=section yellow id=section1> <div id=content-wrap1 class=content-wrap>
I have the following: $(content).filter(p:first).text(); where content = <div> <div> <div> <p>adsdas</p> <p>dsa</p> <p>dsa</p>
I have the following code generating content on my site: <div class=content id=links> <?php
I have following script: jQuery('#content-page-<?php echo $post->ID ?>') .data('content','<div class=page-content><?php echo $post->post_content; ?>'); In
Lets say I have the following content, <div id=sectionA></div> <div id=sectionB></div> <div id=sectionC></div> $(#sectionA).bind(keydown,
Having read around it appears this should be possible. I have the following content
I have the following HTML5 content: <section contenteditable=true id=editable class=ui-selectee ui-selected> <span>something</span> <span>something</span> <span>something</span>
I have a xPage with following content: <xe:restService id=restService preventDojoStore=false> <xe:this.service> <xe:viewJsonService viewName=vwChartData contentType=text/json>
I have a HTML table with following content. <table class='main'> <tr id='r1' class='tbl'> <td>V1</td>

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.