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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:20:14+00:00 2026-05-15T06:20:14+00:00

Why all elements turn red? I only intend to turn <p> red. <ul> <li>list

  • 0

Why all elements turn red? I only intend to turn <p> red.

<ul>
  <li>list item 1</li>
  <li>list item 2</li>
  <li>list item 3</li>
</ul>
<p>a paragraph</p>

<script>
$('li').add('p').css('background-color', 'red');
</script>
  • 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-05-15T06:20:15+00:00Added an answer on May 15, 2026 at 6:20 am

    $('li') is selection all the li
    $('li').add('p') is adding p tag into selected all the li
    $('li').add('p').css('background-color', 'red') is changing all the li and p backgroundColor to red.

    from jQuery.add API

    Given a jQuery object that represents
    a set of DOM elements, the .add()
    method constructs a new jQuery object
    from the union of those elements and
    the ones passed into the method. The
    argument to .add() can be pretty much
    anything that $() accepts, including a
    jQuery selector expression, references
    to DOM elements, or an HTML snippet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(b).bind(contextmenu,function(e){ thiselementselected = e.target $(#add).bind(click,function(e){ thiselementselected.css(font-color, red); return false }); $(#remove).bind(click,function(e){ thiselementselected.css(font-color, ); return
Following this example, I can list all elements into a pdf file import pyPdf
Background A project installs some files that contain all the elements to define a
I'm looking for a ClearCase command that will list all the elements that are
Is there a way to initialize all elements of an array to a constant
What's the best way to get an array of all elements in an html
I'm trying to use XPath to find all elements that have an element in
Given this XML, what XPath returns all elements whose prop attribute contains Foo (the
I have the following code: // Obtain the string names of all the elements
I'm running through an XML document, selecting all the elements, and creating links based

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.