javascript - uncaught syntaxerror unexpected token in Chrome in jquery replaceWith -
this question has answer here:
- new line in javascript alert box 18 answers
jquery('div#top').replacewith('<div id="top"> </div>')
chrome says uncaught syntaxerror unexpected token in first line. dont know whats error here. trying replace top div.
fyi -- replacing whole data of div top mine. placing lot of div`s inside top havent pasted here.
javascript strings can't span across multiple lines. either have add newline escape sequences:
jquery('div#top').replacewith('<div id="top">\n\n</div>')
or add backslashes @ end of each line:
jquery('div#top').replacewith('<div id="top">\ \ </div>')
or use .html()
(assuming weren't trying rid of attributes on element):
jquery('div#top').html('')
or .empty()
:
jquery('div#top').empty()
Comments
Post a Comment