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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:32:56+00:00 2026-06-02T07:32:56+00:00

I wan to get the content within the < p > tag using jQuery.

  • 0

I wan to get the content within the < p > tag using jQuery. So I can have a Java variable with each players name. The jquery code sets playerN1 as a blank string instead of the players name. I was wondering why the text() was not grabbing the players name (whats within the < p > tags)?

<!-- HTML -->
<div class="match1">
  <div id="m1.p1" class="col3 first last bracket_player1">
    <p class="name">Player1 Name</p>
  </div>
  <div id="m1.p2" class="col3 first last bracket_player2">
    <p class="name">Player2 Name</p></div>
  </div>
</div>
<div class="match2">
  <div id="m2.p1" class="col3 first last bracket_player1">
    <p class="name">Player1 Name</p>
  </div>
  <div id="m2.p2" class="col3 first last bracket_player2">
    <p class="name">Player2 Name</p></div>
  </div>
</div>

 

// The jQuery
for (i = 0; i < 7; i++)
{
   var match = "m" + i;
   var elementID = "#"+match+".p1 "+"p";
   var playerN1 = $(elementID).text();
   console.log(elementID);
   console.log(playerN1);
}
  • 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-02T07:32:58+00:00Added an answer on June 2, 2026 at 7:32 am

    It’s because of the . in the ID. #m1.p1 is interpreted as ID=m1 AND class=p1. You need to either escape the . (with 2 \s).

    var elementID = "#"+match+"\\.p1 "+"p";
    

    Or use the [id=""] selector.

    var elementID = "[id='"+match+".p1'] "+"p";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the wan IP address for my machine programmatically using C#
I wan to get id from the gridview and using this code string UserID
i wan to create a program that can get the application name i can
Hai Guys, How to get wan ip address of my user using php....
I am using iPhone to get data from my web service. Because I wan't
I can get all the documents in Google Docs using public DocumentsFeed GetDocs() {
I wan to get the value of only one week. I am using the
i am fetching a page using get ajax call. $.get('/notification/viewmessage',{user:username},function(data){ //my code here });
I wan't to get data's from CallLog.Calls.CONTENT_URI in non Activity classes. Am using cursor
i have this problem that i can't solve for days now...here is my code.

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.