using ' in javascript code
I am using a tooltip plugin (qTip 2.0) and trying to specify content for the tooltip.
I get an error unterminated string literal
Here is the code:
<script type="text/javascript">
var $j = jQuery.noConflict();
$j('.tool').qtip({
content: 'Don\'t want...',
position: {
my: 'bottom left',
at: 'top left',
target: $j('.tool')
},
style: {
classes:
'ui-tooltip-dark ui-tooltip-shadow ui-tooltip-rounded ui-tooltip-tipsy'
}
});
</script>
In the Content you will see the word Don't
I understand that JS will see the '
as an end to the content
how do I get it to read Don't properly?
I have tried Don\'t
and that did not work. I have tried changing '
to "
and that did no开发者_StackOverflowt work.
I know there is a way around this I cannot remember though! Help!
Try putting double quotes around the content with the single quote, should fix it.
...
content: "Don't want...",
...
Does this help?
Use the escape character. Example:
var content = 'It\'s the escape character you want.';
Don't know why the escape character isn't working. But you could also try the HTML equivalent for the \ symbol
\
精彩评论