jquery - How to break the html in append()? -


any trick can use break html in append()?

for instance, great!

// append popup displaying security checking form. $(document.body).append(" <div id='popup-result' class='popup-outer'> <div class='popup-inner'>     <div class='close'><a href='#' class='button-close'>x close</a></div>     <div class='respond-message'></div>     <div class='form-confirm'></div> </div> </div>"); 

so don't have html in 1 line - it's difficult read , debug!

you have 2 options. can use new line literal syntax:

// append popup displaying security checking form. $(document.body).append("\ <div id='popup-result' class='popup-outer'>\ <div class='popup-inner'>\     <div class='close'><a href='#' class='button-close'>x close</a></div>\     <div class='respond-message'></div>\     <div class='form-confirm'></div>\ </div>\ </div>"); 

this works, may confuse ides (visual studio last time tried it. or can make each line it's own string , concatenate strings if don't want new lines:

// append popup displaying security checking form. $(document.body).append( "<div id='popup-result' class='popup-outer'>" + "<div class='popup-inner'>" +     "<div class='close'><a href='#' class='button-close'>x close</a></div>" +     "<div class='respond-message'></div>" +     "<div class='form-confirm'></div>" + "</div>" + "</div>"); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -