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 9190937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:34:09+00:00 2026-06-17T20:34:09+00:00

Possible Duplicate: Checking if an html element is empty with jQuery I have an

  • 0

Possible Duplicate:
Checking if an html element is empty with jQuery

I have an empty div like this:

<div id="cartContent"></div>

I need to check if it’s empty. If it’s empty it needs to return true and then some

elements are added. If not it returns false and some other function executes. What’s the best way to check if there are any

elements in the div?

Thanks

  • 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-17T20:34:10+00:00Added an answer on June 17, 2026 at 8:34 pm

    You can use native JavaScript:

    if document.getElementById('cartContent').innerHTML === "" {
    

    You can use .is():

    if( $('#leftmenu').is(':empty') ) {
    

    Or you could just test the length property to see if one was found:

    if( $('#leftmenu:empty').length ) {
    

    You can use $.trim() to remove whitespace (if that’s what you want) and check for the length of the content:

    if( !$.trim( $('#leftmenu').html() ).length ) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Check if inputs are empty using jQuery I have form and textboxes,
Possible Duplicate: jQuery: Checking if next element exists I'm implementing a custom slider using
Possible Duplicate: checking if pointer points within an array If I have an array
Possible Duplicate: Checking for an SQL result in VB.NET I have login form which
Possible Duplicate: How to check network type in iPhone app I would like to
Possible Duplicate: Checking if array is multidimensional or not? How do I check whether
Possible Duplicate: GCC STL bound checking Is there something like a automatic debug version
Possible Duplicate: What does javascript:void(0) mean? I am checking many sites and I have
Possible Duplicate: How do I check a checkbox with JQuery or Javascript? I'm trying
Possible Duplicate: Checking if an associative array key exists in Javascript I have a

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.