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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:42:12+00:00 2026-05-24T15:42:12+00:00

I am new to JQuery, and I am attempting writing code using PHP, HTML,

  • 0

I am new to JQuery, and I am attempting writing code using PHP, HTML, and JQuery.

I want to replace all of the <?php echo $var; ?> in my HTML with tags that have id’s, instead. For example, I want to have something like <div id="name"></div> which would then use a $("#name") to have it display something in that div field.

My questions:
Does it have to be a <div> tag with that id when I call the #name in jquery? Or can it be in any tag and still have the same effect? –Would this work as well: <a href='alink'><div id="name"></div></a>.
What if I want to put tags with id’s to replace the alink–What tags would be good for that?

Any help appreciated.

  • 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-24T15:42:13+00:00Added an answer on May 24, 2026 at 3:42 pm

    You can add an id to any field. However, you can only use that particular id ONCE per page.

    Ex.

    <div id="name"></div>
    <p id="name"></div>
    <a id="name"></a>
    

    The above is invalid and will cause problems if you use $('#name') in your jQuery. If you want to alter multiple things, like shown above, you are better off using a class and a different kind of selector:

    <div class="name"></div>
    <p class="name"></div>
    <a class="name"></a>
    
    $('.name')
    

    This will select both of the elements.

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

Sidebar

Related Questions

When writing a new jQuery plugin is there a straightforward way of checking that
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to
In my AIR application, I want to animate an HTML element using jQuery. When
I've been trying to use the new jquery-ui, and all but the resizable function
I have application that brings response via Ajax and creates 5-20 new jQuery click
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
I have some jQuery that loads a new stylesheet like so... $('head').append('<link rel=stylesheet type=text/css
I'm currently attempting to retrieve a list of objects from my database using jQuery.
I am working on a simple web app using jquery mobile. I am attempting
I am new to Jquery Mobile and attempting to learn it as I redevelop

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.