Thursday 15 January 2015

JavaScript string literal in object literal syntax error -


I'm trying to insert some HTML mark-ups later in some array to retrieve it. My editor throws a syntax error on the description 1 line, I do not know why any help would be very commendable. Thanks to the code below.

  var modalcontent = {description1: '& lt; Div id = "description" & gt; & Lt; Div class = "tbc" & gt; & Lt; Label class = "tbc" for = "tbc" & gt; Details & lt; / Label & gt; & Lt; / Div & gt; & Lt; Div class = "tbc" & gt; & Lt; Input type = "text" class = "TBC" name = "description" id = "TBC" placeholder = "enter details" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End details div - & gt; You have an unpublished string literally javascript strings by default.   

are multiple lines.
  var modalcontent = {description1: '& lt; Div id = "description" & gt; & Lt; Div class = "tbc" & gt; '+' & Lt; Label = "TBC" for label = "tbc" & gt; Details & lt; / Label & gt; '+' & Lt; / Div & gt; '+' & Lt; Div class = "tbc" & gt; '+' & Lt; Input type = "text" class = "tbc" name = "description" id = "tbc" placeholder = "enter details" & gt; '+' & Lt; / Div & gt; '+' & Lt; / Div & gt; '+' & Lt;! --end Description div - & gt; '}   

Alternatively, you can create multi line strings using the \ character, only work in new implementations We do. See or.

Note: This is not usually the best idea to store HTML in the string, it makes it difficult to debug and work with it. You can usually use templates. It is not that there are no good use cases, it is hardly the case.

No comments:

Post a Comment