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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:09:25+00:00 2026-05-23T22:09:25+00:00

I am passing an id into a function as a string. I want to

  • 0

I am passing an id into a function as a string. I want to use that ID to then change the background color. I have used:

$("#"+address).css("background-color", "#3399FF");

but it is not changing the background color and when I do a:

console.log($("#"+address).css("background-color"));

It is coming up as undefined.

How can I pass the variable address into jquery?

Thanks for your help.

Kevin

  • 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-23T22:09:25+00:00Added an answer on May 23, 2026 at 10:09 pm

    I’m going to take a stab in the dark here,

    You say you are using and address as an id

    1234 Any st.
    

    by appending a #,

    #1234 Any st.
    

    The jquery selector becomes, find the element with ID 1234, then any children of type Any, then any children of type st with class ”.
    Which looks like

    <div id="1234">
      <any>
         <st/>
      </any>
    </div>
    

    You need to escape spaces, periods, hell everything here !”#$%&'()*+,./:;<=>?@[]^`{|}~

    As per the specification, an id should

    must begin with a letter ([A-Za-z]) and may be followed by any number of letters,
    digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
    

    So to escape a valid id use,

    function jq(myid) { 
        return '#' + myid.replace(/(:|\.)/g,'\\$1');
    }
    

    as per HERE

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

Sidebar

Related Questions

I have A $param that I am passing into a template. I wish to
I have a function that reads user input from std::cin, and I want to
The following code says that passing the map as const into the operator[] method
I am passing a variable to a function that executes a query The MySQL
I have a c function (dbread) that reads 'fields' from a 'database'. Most of
I am using a function (TinyXML's TiXmlElement::QueryValueAttribute(const std::string &name, T * outValue ) that
I want to pass the string value which I get from the textarea into
I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
Passing an undimensioned array to the VB6's Ubound function will cause an error, so

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.