Using \ for template of html in javascript [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Why is it I got error of unexpected illegal of TOKEN using below code?
var html = '<div id="wrap">\
<img style="width:100%;display:block">\
<div>\'
console.log(html);
I use \ to escape, it should work fine..

Here is the problem:
<div>\'
You are escaping the closing quote.

Try this
var html = '<div id="thermal-close-sales-wrap">\
<img style="width:100%;display:block">\
<div>'
console.log(html);

Related

Having issues with Echo PHP/JS [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I hava an issue with my PHP/javascript code
I dont understand how to escape code it breaks my brain
echo "<button id='$date' onclick = 'document.getElementById('$date').style.display ='none'';>$date</button>";
anyone have an idea?
Everything after getElementById(' is not interpreted anymore
You have to correct the quotes.
echo "<button id=`$date` onclick = `document.getElementById('$date').style.display ='none'`;>$date</button>";
If button id is from php, you have to correct this too.
This should work
echo "<button id='$date' onclick = \"document.getElementById('$date').style.display ='none'\";>$date</button>";

How to include Micro symbol (µ) in Javascript regex? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I need to use the following regex in my Javascript code:
/\D*(\d+)\s*([TGMkmµnp]).*/g
However, the µ symbol is causing syntax error.
How can I fix this?
The error message is:
At "value = str.replace(/(+)(TGMk"
error110: SYNTAX ERROR while lexing character "µ".
I am using TestComplete software.
My code is as simple as this:
function GetVoltageDbl(str)
{
var value = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$1");
var prefix = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$2");
Log.Message(value);
Log.Message(prefix);
}
Try replacing µ with \u03BC as follows:
/\D*(\d+)\s*([TGMkm\u03BCnp]).*/g
Please try this \µ . It's need to help

Uncaught SyntaxError: missing ) after argument list [Javascript Syntax Error] [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I've got this error Uncaught SyntaxError: missing ) after argument list when trying to
var email = 'admin#admin.com';
$('<div class="shareBtnBlockOlly"><a class="tweet" href="javascript:Share.twitter('+email+')" target="_blank">Twitter</a></div>').insertAfter('.objectCollectModalShareContent h4');
Where is my problem? Can't solve this today, i guess im to sleepy or just too broken before weekends..
$('<div class="shareBtnBlockOlly"><a class="tweet" href="javascript:Share.twitter(\'' + email + '\')" target="_blank">Twitter</a></div>').insertAfter('.objectCollectModalShareContent h4');
Because you started with double quotes, add parameters with single quotes.

Retuning a string in PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I wanted to return following string, but I still couldn't get it done right for couple of hours. CAn anyone tell me what did I do wrong? Thank you.
<?php
return 'rs...#gmail.com.com';
?>
You have single quotes in the JavaScript code in your onclick attribute. You need to escape these by placing a backslash before each single quote.

Is there anything wrong in this Javascript line? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
my code is not working after adding style property, here it is:
$("#instaUser").append("<figure style='"display:inline "'><img id='"+i+"' src='"+data.data[i].profile_picture+"' alt='pic number "+i+"' height='"+200+"' width='"+200+"'> <figcaption>#"+data.data[i].username+"</figcaption></figure>");
could it be that i used the " in a wrong way?
You don't need double quotes wrapping display: inline
This is correct:
$("#instaUser").append("<figure style='display:inline'><img id='"+i+"' src='"+data.data[i].profile_picture+"' alt='pic number "+i+"' height='"+200+"' width='"+200+"'> <figcaption>#"+data.data[i].username+"</figcaption></figure>");

Categories

Resources