jquery - Div structure created in javascript is different in the actual DOM -


I am creating a relatively complex nested div structure in a javascript loop on a bunch of JSON reaction objects from the instagram API. Setting the URL of the image within a specific bootstrap dival structure. However, anyhow, when I look at the Dom structure, it is completely different that the map I created is loop.

My JS file has a loop:

  htmlz = "
div class =' ​​col-md-6 '& gt; & lt; div class =' ​​container ' & Gt; "count = count + 1;} and if (count == 9) {htmlz
div class = 'col-md-6' & gt; & lt; Div class = 'container' & gt; div class = ' line-fluid' & gt; div class = 'col-md-6' & gt; Lt; img src = '"+ item.images.low_resolution.url +"' + + rounded_style + "& gt; & lt; / div & gt;;; count = count + 1;} and if (calculation == 13 } {Htmlz + = "& lt; / div> gt class = 'col-md-6' & gt; & lt; img src = '" + Item Images = standard_resolution.url + "' + rounded_style +" & Gt; & lt; / div & gt; & lt; / div & g T; & lt; / div & gt; "; count = count + 1;} and if (count == 5) {htmlz +" & lt; / div> gt; & lt; / div & gt; & lt; Div class = 'row-liquid' & gt; & lt; div clas S = 'col-md-4' & gt; & Lt; Img src = '"+ item.images.low_resolution.url +"' + + rounded_style + "& gt; & lt; / div & gt;"; Calculation = count + 1; } And if (calculation == 4 || 12) {htmlz + = "

In this way, I can change the DOM to #myflsadventure Element

  .container .ro-fluid .col- md-6 .coll-md-6 container .o-fluid.cool-MD-6 .col-md -6 .oo- Fluid Coal-MD-6. Coal-MD-6 .o-fluid .ol-MD-4 .Col-MD-4. Coal-MD-4 .Col-MD-4 .Oro-Liquid .col-md- 6. Container .Oo-Fluid Coal-MD-6. Coal-MD-6 .OR-Fluid .col-md-6 .col-md-6 .col-md-6   < P> I'm getting this structure  
  .container .row-fluid .col-md-6 .col-md-6 .col-md-6 .col-md-6 .col -md-6 O-fluid .col-md-4 .col-md-6 .col-md-6 .col-md-6 .oop-liquid .col-md-6 .col-md-6 .col-md-6 < / Code>  

Anyway, when I make a div element, then automatically adds the closing tag, and therefore not nesting my elements I did not know how to avoid this behavior.

 < Code> else if (1 || 3 || 11) {htmlz + = "& lt; Div class = 'row-fluid'> div class = 'col-md-6' & gt; & lt; img src = '" + item.images.low_resolution.url + "'+ + Rounded_style +" & gt; & Lt; / Div & gt; ";}   

This section seems incorrect in two ways. First of all, you are checking the boolean values ​​between numbers since one of those numbers is 1 (a 'true' value ), It will always be true, even if you are not counting 1. Plus, this can be done by the design, but you are not raising your counting variables here.

There are also some other places Where you are not specifying your 'clause' if the clause (eg calculation == 6 || 7 || 8), h The bigger picture, however, is that you can think again what you are doing here, this is a complex argument which describes very little that it will rotate and Why it is difficult to turn back after debugging or modifying this code, it can be very easy to save time later.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

C++ Array Type Not Assignable in Copy Constructor -