javascript - JQuery loop to append text not appending -


i try create loop jquery 2.1.0 appends paragraph each loop. code far

for (var = 0; < 3; i++) {    var hobby = prompt("tell me 1 of hobbies!");    $("body").append("<p>" + hobby + "</p>");  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

so prompt comes , works fine doesn't append... , doesn't loop. appreciated.

try use native js.

for (var = 0; < 3; i++) {  	var hobby = prompt("tell me 1 of hobbies!");  	var p = document.createelement('p');  	p.innerhtml = hobby;  	document.body.appendchild(p);  }


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -