Search code examples
javascriptwhitespaceprototypeparagraphs

Quotation Marks (" "), Paragraph and White Space causing issues


I am using Prototype tooltip and I am not able to use Quotation Marks (" "), Paragraph etc. in the content. Below is the sample.

<div style="margin-right: 2px" id="bio" class="masters-bio">Bio</div>

    <script type="text/javascript" language="javascript">
        new Tip('bio', "Lorem ipsum "dolor" sit amet, consectetur adipiscing elit. Ut rhoncus mollis tincidunt. Curabitur rhoncus suscipit dui, quis tristique est posuere in. Nam in pretium tellus.", {
            title: "Bio",
            closeButton: true,
            showOn: 'click',
            hideOn: { element: 'closeButton', event: 'click'},
            stem: 'bottomMiddle',
            hook: { target: 'topMiddle', tip: 'bottomMiddle' },
            offset: { x: 0, y: -2 },
            width: '300px',
            style: 'protogrey'
        });
    </script>

Solution

  • Use backslash to escape you're quotes. Just put \ before each of them inside of your string. Example:

    "Lorem ipsum \"dolor\" sit amet"