javascript - Creating a inside a dynamically -


I am trying to create a div inside a p with a click function. But it seems that I do not want to close my P element, after reading it apparently, it seems that if the P element immediately follows a div in this case, then it does not require the end tag at the end.

  & lt; Div class = "main" & gt; & Lt; / Div & gt; & Lt; Div class = "content-list" & gt; & Lt; Ul class = "info" & gt; & Lt; / Ul & gt; & Lt; / Div & gt;   

I am going to attach to this function:

  var $ contentHandler = $ (". Content-list"); Var $ Mainhanger = $ ("main"); Var $ infoHandler = $ ("info"); Var circle quarter = 1; $ MainHandler.click (function () {var html string = "& lt; li class = '" cyclical + "' gt; 

var color = & lt; div class = 'circle-color-input' content disabled autocorrect = 'off' & gt; Type a color & lt; / div & gt ;; & lt; / p & gt; & lt; p class = 'circle- Radius' & gt; & lt; / p & gt; & lt; p square = 'circle' & gt; & lt; / li & gt; "$ infoHandler.append (htmlString); Circle ++;});

Here is the code for

Is there a way around this?

Thank you!

You just not in div Code> P , because the only content in a p element is to allow content to be written (as you've read in the document), which is usually inline elements Means that this is the reason that any p (or any other flow element like ul or shape ) immediately p < / Code> but closes the code, which will close the p And can be born as a brother, not the child, in the dome.

You can use a span instead, and make it appear as a block if necessary: ​​

  Var htmlString = "& lt; li class = '" + circleCounter + "' gt; & lt; p class = 'circle-color' & gt; var color = & lt; span class = 'circle-color-input' ContentEditable autocorrect = 'off' & gt; Type a color & lt; / span & gt;; & lt; / p & gt; & lt; p class = 'circle-radius' & gt; & lt; / p & gt; & lt; p square = 'circle' & gt; & lt; / p & gt; & lt; / li & gt; "   

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -