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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:37:08+00:00 2026-05-21T04:37:08+00:00

I am trying to add some html after a specific h1 tag. The line

  • 0

I am trying to add some html after a specific h1 tag. The line of html is long and I would like to break it down to multiple lines within the .after function.

Below is the code:

$(document).ready(function() {
    $('#content-main-cell h1').addClass('index-title');
        $('.index-title').after('<div class="mds-logo"><img src="http://marines.mil/unit/marforres/4thMarDiv/23rdMar/1stBn/img/battalion-logo.jpg"/></div>');
});

How do I break this down into multiple lines within the code and have it work ? Do I use a ; at the end of each line ?

  • 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-21T04:37:09+00:00Added an answer on May 21, 2026 at 4:37 am

    You can continue a string literal on a subsequent line with a backslash:

    $(document).ready(function() {
        $('#content-main-cell h1').addClass('index-title');
            $('.index-title').after(
                '<div class="mds-logo">\
                <img src="http://marines.mil/unit/marforres/4thMarDiv/23rdMar/1stBn/img/battalion-logo.jpg"/></div>'
            );
    });
    

    This is defined by Section 7.8.4 (“String Literals”) of the spec. I don’t know that I’d trust all parsers to get it right, not least because it was just introduced in the 5th edition specification, but it appears that the spec was codifying previous standard practice as even IE6 understands it. (As do — in my tests — IE7, IE9, Chrome, Firefox, Opera, and Safari.) Of course the whitespace at the beginning of the next line is part of the string, which probably isn’t what you want.

    Alternately, just use string concatenation:

    $(document).ready(function() {
        $('#content-main-cell h1').addClass('index-title');
            $('.index-title').after(
                '<div class="mds-logo">' +
                '<img src="http://marines.mil/unit/marforres/4thMarDiv/23rdMar/1stBn/img/battalion-logo.jpg"/></div>'
            );
    });
    

    You’re not in a tight loop, so even if the parser doesn’t concatenate on the fly (and a good one will), having the concat operation occur when you call after won’t do any real harm.

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

Sidebar

Related Questions

I need to add some html right after the body tag so like :
I'm trying to add some HTML formatted text to Word using Office Interop. My
I'm trying to add some additional key/value pairs to an NSMutableDictionary, using: Tag *tag1
I am trying to add some instance variables in helpers like the following: module
I am currently trying to pass in some html into the the :after pseudo
I'm trying to add some help messages after each field in form in symfony2.
Im trying to add some short file names to a Wise installer to fix
I am trying to add some custom build steps to my headless build process
I'm trying to add some accessibility for screen readers into a Flash application, and
I'm trying to add some security to my ASP.NET 1.0 MVC app (VB), but

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.