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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:20:56+00:00 2026-06-04T19:20:56+00:00

Div1.InnerHtml = (someString); -VS- Div1.InnerHtml += (someString); I notice they both do the same

  • 0
Div1.InnerHtml = (someString);

-VS-

Div1.InnerHtml += (someString);

I notice they both do the same thing, but is there any real difference whether I have the + in there or not?
Also.. What’s the difference between InnerText & InnerHtml?

  • 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-04T19:20:58+00:00Added an answer on June 4, 2026 at 7:20 pm

    += will append (someString) to the existing value of Div1.InnerHtml, whereas = will replace the value of Div1.InnerHtml with (someString).

    If the results are the same then the starting value of Div1.InnerHtml is likely null or string.Empty ("")

    Regarding InnerText vs InnerHtml: InnerHtml might return something like <h1>Hello World</h1> whereas InnerText would return Hello World (the value of the element without the actual HTML element).

    Consider these cases:

    string someString = "Hello";
    string innerHtml = "";
    
    innerHtml += someString; // result will be "Hello"
    

    string someString = "Hello";
    string innerHtml = "";
    
    innerHtml = someString; // result will be "Hello"
    

    string someString = "Hello";
    string innerHtml = "World";
    
    innerHtml += someString; // result will be "HelloWorld"
    

    string someString = "Hello";
    string innerHtml = "World";
    
    innerHtml = someString; // result will be "Hello"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in a div , with IDs of table1 and div1
I have a page like below; <style type=text/css> #div1 { height: 100px; background-color: #CCCCCC;
I have div1 and div2, upon clicking copy button I want the text in
$('#div1').children('div:last').css('border-bottom', ''); $('#div2').focus(); I am using above and it works fine with ie but
I have a wrapper div1, with div2 inside which contains a string. When i
I have two divs: div1 and div2 . Maintaining the original css styles applied
I have a div ( div1 ) that has its position, width, height, everything
I have the following jQuery: $(#div1).animate({ width: '160' }, 200).animate({ width: 'toggle' }, 300
I have: $(document).ready(function () { $(.div1, .div2, .div3, .div4, .div5).draggable(); $(#menu).click(function () { $(<div
$(document).ready(function() { $(.div1).click(function() { $(.div2).stop().animate(...); }); }); div1 and div2 are both divs in

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.