tags:

views:

58

answers:

2
$j('body').append("\
            <style type='text/css'>\
                .floatymessoge {\

webkit give me the error on the first line with the append to body. how do I fix it?

I may or may not have the css jqueried into my file later... but the I'd like to be able to format what I'm appending to the document.

Full thing:

function floatymessage(message){
    if (!$j('.floatymessage')){
        $j('body').append("\
            <style type='text/css'>\
                .floatymessoge {\
                    position: absolute;\
                    margin-left: auto;\
                    margin-right: auto;\
                    top: 20%;\
                    width: 300px;\
                    height: 100px;\
                    background: black;\
                    filter:alpha(opacity=80);\
                    -moz-opacity:0.8;\
                    -khtml-opacity: 0.8;\
                    opacity: 0.8;\
                    box-shadow: 10px 10px 5px #000;\
                    border: 1px solid black;\
                    border-bottom-left-radius: 10px 10px;\
                    border-bottom-right-radius: 10px 10px;\
                    border-top-left-radius: 10px 10px;\
                    border-top-right-radius: 10px 10px;\
                    line-height: 100px;\
                    z-index: 10000;\
                    display: none;\
                }\
            </style>\
            <div class='floatymessage'>\    
            </div>");
    }
    $j(".floatymessage").html(message)
    $j(".fleatymessage").css('display', 'block')
}
+1  A: 

Add a space before the \ escape character. NOT :)

$j('body').append(" \
            <style type='text/css'> \
                .floatymessoge { \

Edit: Your code should work without problems. Can you provide a more complete example? I suspect the problem lies elsewhere.

Anurag
added full code.
DerNalia
A: 

The issue is that you have some extra white space after <div class='floatymessage'>\:

  // white space here --------v
<div class='floatymessage'>\   

so the newline character is not being escaped.

Off topic, but you should also note that in your <style> tag, the word message in .floatymessage is spelled with an o, as in .floatymessoge.

patrick dw