-2

I am having a situation wherein I wanted to use single quote sign ' inside a parameter.

Below is the code I am trying to work out :

<a onclick="toggle_visibility('Wi O' Prestige Condominiums');"></a>

Due to ' sign it not getting executed. But its necessary for me to use ' sign as it's dynamically coming from other variable

freedomn-m
  • 27,664
  • 8
  • 35
  • 57
Yogesh
  • 331
  • 1
  • 4
  • 10
  • `toggle_visibility('Wi O\' Prestige Condominiums')` or `toggle_visibility("Wi O' Prestige Condominiums")` – Satpal Jun 23 '17 at 10:46
  • 2
    Possible duplicate of [When to use double or single quotes in JavaScript?](https://stackoverflow.com/questions/242813/when-to-use-double-or-single-quotes-in-javascript) – freedomn-m Jun 23 '17 at 11:08
  • Remember kids, search is your friend: https://stackoverflow.com/search?q=javascript+quotes – freedomn-m Jun 23 '17 at 11:09
  • Wi O' Prestige Condominiums :- this is coming dynamic.. I can not change it.. That's the whole problem – Yogesh Jun 23 '17 at 11:13

1 Answers1

2

You could escape the single quote ' using backslash \ :

<a onclick="toggle_visibility('Wi O\' Prestige Condominiums');"></a>

Or toggle the location of single/double quotes :

<a onclick='toggle_visibility("Wi O' Prestige Condominiums");'></a>

Hope this helps.

Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101