Reputation: 37
I know this is potentially a common question however I believe the logic and the code appear correct, yet it still seems to loop until the browser crashes.
$("#orderview").click(function(){
do {
$(".row1").clone().appendTo(".cardbox");
var i = $( "listrow" ).length;
}
while (i < 10);
});
My function is creating Listrow class DIV's until there are 10 of them. My HTML starts with 1 DIV.
<div class="listrow news" id="row-a">
<div class="l-padding floatleft">
<div id="redditThumbnail"></div>
<div class="articleheader news">
<p class="mediatitle alignleft" id="redditTitle">
</p>
<p class="mediumtext floatleft alignleft">
Submitted by
</p>
<div id="redditUsername"></div>
<div class="half floatright">
<p class="mediatext floatright s-color bold h-s-margin">
TEST
</p>
<p class="mediatext floatright p-color bold">
ACTION
</p>
</div>
</div>
</div>
</div>
The logic behind my attempted JS was:
Am I missing something? Thanks in advance for the assistance.
Upvotes: 0
Views: 46
Reputation: 12959
change :
var i = $( "listrow" ).length;
to :
var i = $( ".listrow" ).length;
Upvotes: 3