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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:40:13+00:00 2026-05-31T06:40:13+00:00

<div id=content> <textarea id=#example-1> </textarea> <textarea id=#example-2> </textarea> </div> and Jquery var xyz =

  • 0
<div id="content">
<textarea id="#example-1">
</textarea>
<textarea id="#example-2">
</textarea>
</div>

and Jquery

var xyz = $("content##example-1").val();

This code doesn’t work for me. It crashes – shows undefined. When I delete “#” from div from textarea and one “#” from JS code it works. It need to works with id with “#”.
Can I put variable into $() after quotation marks? E.g.:

$("content#"variable)
  • 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-31T06:40:15+00:00Added an answer on May 31, 2026 at 6:40 am

    Escape the special character in the ID, and remove that content part. Because element IDs must be unique, an ID selector will match at most one element. Therefore, anything beyond that is overspecified.

    var xyz = $("#\\#example-1").val();
    

    Better still, don’t use a special character in the ID at all:

    <div id="content">
        <textarea id="example-1">
        </textarea>
        <textarea id="example-2">
        </textarea>
    </div>
    
    var xyz = $('#example-1').val();
    

    how about $(“content#”variable)? Is it possible? Is it exist any possibility to deal with it?

    That’s not valid JavaScript; you need to use string concatenation. Also, the selector 'content' matches elements with tag name content, which is not what you want. Believe me: just get rid of the content part entirely.

    Then use the jq function described in the jQuery FAQ that I linked.

    var xyz = $(jq(variable)).val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select an anchor inside a div like this <div class=response content>
Here is an example: I write html code inside of textarea, then I swap
I have this html: <div class=box id=n5> <p class=text>Lorem ipsum dolor sit amet</p> <textarea
This code is from the demo of modal confirmation on the jQuery site. <script
I got this $('#password').change(function() { var toSha1 = $('#msisdn').val() + $('#password').val(); var authCode =
I have this simple ajax code, for some reason it wont load content onto
I have a contentEditable div with following text for example: <div contentEditable='true'> This document
We have a div of content (#content) and on the right hand side of
In IE6 the left of the #right-content DIV is cut off. I've been playing
The page has a container div which holds multiple content divs. Each content div

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.