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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:36:36+00:00 2026-06-14T21:36:36+00:00

What does this: ‘+variable+’ mean? I use jQuery append method to add some DOM

  • 0

What does this: ‘+variable+’ mean?

I use jQuery append method to add some DOM element:

$('#story_pages').append('<div><button value="'+window_value+'" onclick= "reload_to_canvas(this.value)" ><img id="w'+window_value+'", src=white_data_URL, width="100px", height="100px"/> </button></div>');

Actually, I don’t why this works…
If I just write

value= window_value 
img id= w+window_value

,and use the selector
$(‘#(w+window_value)’)
to find the element. It must fail.

What is this operator? ‘+variable+’

And why should we use the weird notation “‘+variable+'”?

When should we use this notation?

  • 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-14T21:36:37+00:00Added an answer on June 14, 2026 at 9:36 pm

    What is this operator? ‘+variable+’

    That isn’t an operator.

    ' ends a string literal

    + is a concatenation operator.

    variable is a string variable

    + is another concatenation operator.

    ' starts a new string literal.

    And why should we use the weird notation "'+variable+'"?

    The two string literals have " characters in their data.

    The object is to construct this:

    '<element attribute="value">'
    

    When the value is a variable

    var myValue = "value";
    '<element attribute="' + value + '">'
    

    Generating code from code by string concatenation always gives ugly code, which is relatively hard to maintain. I’d approach the problem with a more verbose approach:

    var content = $("<div>");
    var button = $("<button>");
    button.val(window_value);
    button.on('click', function() { reload_to_canvas(this.value); });
    var img = $('<img>');
    img.attr('id', 'w' + window_value);
    img.attr('src', 'white_data_URL');
    // width and height can be handled in CSS
    button.append(img)
    content.append(button)
    $('#story_pages').append(content)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does this mean I can't update another table from a trigger if I'm using
Does this work in > iOS 5? .element { background: url(images/myImage.jpg) 50% 0 no-repeat
Does this line of Perl really do anything? $variable =~ s/^(\d+)\b/$1/sg; The only thing
Does this method check and replace randoms in the array? public void generateNumbers() {
Does this seem correct? I'm trying to port this checksum method from C to
What does this mean exactly? I'm doing something like this: File.Copy(@\\foo\bar\baz.txt, @c:\test\baz.txt); MSDN doesn't
does this mean the image will be locked in place no matter what's around
Does this look like a safe salt to use with a password? Any improvements
Does this method look to Web.CurrentUser properties to derive a 'from' address or will
Does this code return an invalid reference to a variable allocated on the stack?

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.