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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:35:24+00:00 2026-06-11T05:35:24+00:00

I have a variable: var remoteControlPage = ‘ <table> <tr> <td class=stats>sadfsadf</td> </tr> </table>

  • 0

I have a variable:

    var remoteControlPage = '
        <table>
            <tr>
                <td class="stats">sadfsadf</td>
            </tr>
        </table>
    ';

and I want to use it in a Jquery .html function like this:

    $("div.devices div.devicePage").html(remoteControlPage);

The problem is the html function wont work unless the new content is in a sing line. And this is not desirable when writing html.

So I was wondering if there is anyway to convert the var remoteControlPage into a single lined variable?

Thanks

  • 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-11T05:35:26+00:00Added an answer on June 11, 2026 at 5:35 am

    You can’t define a variable like this:

    var remoteControlPage = '
        <table>
            <tr>
                <td class="stats">sadfsadf</td>
            </tr>
        </table>
    ';
    

    In any case, you could have a textarea which is filled by the user with the text

    <table>
        <tr>
            <td class="stats">sadfsadf</td>
        </tr>
    </table>
    

    And then you get it:

    var remoteControlPage = mytextarea.value;
    

    But when you do that the text is changed to

    var remoteControlPage = "<table>\n    <tr>\n        <td class=\"stats\">sadfsadf</td>\n    </tr>\n</table>"
    

    Then, if you want to remove the line-breaks, you can do

    remoteControlPage = remoteControlPage.replace(/\s*\n\s*/g,"")
    

    But you don’t need that. If you say that the users will write the HTML, you can use a <textarea>, …

    <textarea id="txt">
    <table>
        <tr>
            <td class="stats">Cell 1</td>
            <td class="stats">Cell 2</td>
        </tr>
    </table>
    </textarea>
    

    …a button, …

    <button id="button">Click me!</button>
    

    … and a output HTML viewer:

    <div id="output">Here will go the output</div>
    

    And then you just need

    $('#button').click(function(){
        $('#output').html($('#txt').val());
    });
    

    Demo: http://jsfiddle.net/bYsTy/6/

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

Sidebar

Related Questions

I have some html in a jQuery variable var banner = $(<div class='banner-textarea'></div>); hot
I have declared this variable in jquery var enabled = false; I want to
I have a jQuery variable like this: var variable = $j(this).val(); Where $j(this) is
I have a variable like var column = $(this).attr('class'); I then need to add
I have a variable called var in SAS/IML. I want to know how I
I have variable which I populate from JSON formated data. Something like: var time=my_data[data.results[i].id].time;
I have a JavaScript variable that stores a websocket connection like so: var ws
I have a variable var 'html' , it contains some html codes .in it
I have a variable like var theUrl = 'http://www.google.com/?q=%s'; then i have a input
I have a variable var functionName=giveVote; What I need to do is, I want

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.