Mohsin
Mohsin

Reputation: 179

how to use single quote inside double quote while double quote already inside single quote?

I have string $html = ' <button onclick="js_func(this, "in this point")"> submit </button>' I want to send a string to js function I am trying with '/'' string '\' also with "/"" string "\" but didn't get the solution yet. Please guide me with correct solution.

Upvotes: 0

Views: 39

Answers (2)

Romain capelleman
Romain capelleman

Reputation: 56

With \==> ' < button onclick="js_func(this, \"in this point\")"> submit < /button>'


Escape quotes in JavaScript

Upvotes: 0

VisioN
VisioN

Reputation: 145478

Just escape it with a backslash as simple as this:

$html = ' <button onclick="js_func(this, \'in this point\')"> submit </button>'

Upvotes: 2

Related Questions