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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:03:37+00:00 2026-06-10T07:03:37+00:00

Simple problem. I have a js variable I want to be concatenated too within

  • 0

Simple problem. I have a js variable I want to be concatenated too within a jQuery selector. However it is not working. No errors are popping up either. What is wrong? How do I correctly concatenate a variable to some text in a jQuery selector.

<div id="part2"></div>

<script type="text/javascript" >

$('#button').click(function () 
{
var text = $('#text').val();    
var number = 2;
$.post('ajaxskeleton.php', {
red: text       
}, 
    function(){
    $('#part' + number).html(text);
    }); 
});


</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-06-10T07:03:39+00:00Added an answer on June 10, 2026 at 7:03 am

    There is nothing wrong with syntax of

    $('#part' + number).html(text);
    

    jQuery accepts a String (usually a CSS Selector) or a DOM Node as parameter to create a jQuery Object.

    In your case you should pass a String to $() that is

    $(<a string>)
    

    Make sure you have access to the variables number and text.

    To test do:

    function(){
        alert(number + ":" + text);//or use console.log(number + ":" + text)
        $('#part' + number).html(text);
    }); 
    

    If you see you dont have access, pass them as parameters to the function, you have to include the uual parameters for $.get and pass the custom parameters after them.

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

Sidebar

Related Questions

I have a simple problem that I have not been able to find an
Very simple problem: I have a Public Sub (in a module) that I want
I have a little simple problem. I want to perform a query on a
I have - I think - a very simple problem I want to align
This seems like a simple problem: I have a WF4 activity that guides the
Hi I am new to PHP and have a simple problem but I have
so I have a simple problem. I have a hover background image change effect,
I have a simple problem with SQL SERVER charindex function. DECLARE @VAR1 varchar SET
I have a simple problem while putting text in multiple table! please have a
I have a simple problem that I've been stuck on for some time and

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.