HTML in JS - Quotes rendered incorrectly

taylorswiftfan
getFeederInfoWindow: function (i) {
    var windowContent = "<button onclick='feeders.getFeederLoadingData(" + i + ",'summer')\">Summer</button>"
}

The method signature is basically: feeders.getFeederLoadingData: function (i, selectedSeason)

When the HTML page is loaded, Chrome inspection shows the <button> is rendered as follow:

Rendered: <button onclick="feeders.getFeederLoadingData(203," summer')">Summer</button>

But this is what I wanted:

Desired <button onclick="feeders.getFeederLoadingData(203,'summer')">Summer</button>

Bit of an embarrassing question, but I cannot figure out how I have messed up the quotes.

Thank you.

Fabian Scheidt

The quote after "onclick" is just a single quote. That should do the job:

getFeederInfoWindow: function (i) {
    var windowContent = "<button onclick=\"feeders.getFeederLoadingData(" + i + ",'summer')\">Summer</button>";
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Javascript is rendered incorrectly

From Dev

AlertDialog with NumberPicker rendered incorrectly

From Dev

Mathjax is incorrectly rendered

From Dev

ImageMagick dashed rectangle incorrectly rendered

From Dev

Inkscape SVGs are rendered incorrectly in Firefox

From Dev

Server-side rendered HTML -> JS Table?

From Dev

Jquery ajax response rendered as HTML instead of JS

From Dev

Form link rendered incorrectly in Twitter Bootstrap Navbar

From Dev

Qt File Dialog Rendered Incorrectly and Crashes

From Dev

Android: Custom seekbar progress drawable is rendered incorrectly

From Dev

How to know HTML page needs to be rendered by JS compiler?

From Dev

Scraping JS rendered page using Requests_HTML is not working as expected

From Dev

How to let string coming with HTML tags to be rendered in React js?

From Dev

Call a js function on an html snippet rendered using ngBindHtml

From Dev

Escaping quotes at the beginning and at the end of the rendered expression

From Dev

vue renders html incorrectly

From Dev

Reading HTML data incorrectly

From Dev

Appending HTML code to a div using JS - without double quotes

From Dev

How to handle quotes in quotes in quotes with jinja/html?

From Dev

Flask HTML emails is not rendered

From Dev

HTML + CSS Rendered colors

From

Go - HTML comments are not rendered

From Dev

HTML is not rendered [Twig] / [Slim]

From Dev

Sitecore Get Rendered Html

From Dev

Gatsby StaticQuery and Rendered HTML

From Dev

Vue syntax rendered in HTML

From Dev

ViewChild on html rendered as innerHtml

From Dev

View is being rendered as html

From Dev

Kendo UI chart series lables rendered incorrectly in PDF generation

Related Related

HotTag

Archive