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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:04:30+00:00 2026-06-17T22:04:30+00:00

I have the below code which works fine. <div id=testdiv></div> <table> <tr> <td class=test

  • 0

I have the below code which works fine.

    <div id="testdiv"></div>
    <table>
        <tr>
            <td class="test" title="two">2</td>
            <td class="test" title="one">1</td>
            <td class="test" title="three">3</td>
        </tr>
    </table>

    <script>
        if(jQuery("td[title='three']").length == 0) {
          jQuery('#testdiv').append('<p>no td</p>')
        }
        else
        {
          jQuery('#testdiv').append('<p>yes td</p>')
        }
    </script>

However I want to say if either title one or three are present. So I tried editing the first line of my script to look like this.

if(jQuery("td[title='three']").length == 0 || jQuery("td[title='one']").length == 0) {

But for some reason it seems as though both three and one need to be there for my statement to be true?

But if I replace the || with the && it works how I want it to? Why is it that the && is working like an || here or am I missing something here?

See fiddle for example

  • 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-17T22:04:31+00:00Added an answer on June 17, 2026 at 10:04 pm

    || is OR, && is AND so if you need both conditions to be met you have to use &&, but you can make this a bit shorter. I’m using $ for convenience but you can replace with jQuery:

    var exists = $('td[title=one],td[title=three]').length;
    $('#testdiv').append('<p>'+ (exists ? 'yes' : 'no') +' td</p>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the code below, which works fine it can be viewed for an
I have this code below which works fine but seems unnecessary as it loops
I have a sample code snippet below which works just fine (I trimmed the
I have a piece of code below which works fine when it comes to
So, I have the code below which works fine when entered into Google's Rich
I have the following code below which works, but I want to insert values
Below is the code I have for sending email which works great. /* *
I have below code which overrides equals() and hashcode() methods. public boolean equals(Object obj)
I have below snippet of code in which TestClass is extending jPanel which is
I want to know is below code correct ? I have following code which

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.