79827403

Date: 2025-11-22 15:39:03
Score: 0.5
Natty:
Report link

I'm trying to append some divs in a main div using jquery. I take some input values and loop for certain values. My code is that. I take 4 values form a form. "name" and "type" are text, while "first" and "last" are two numbers, let's say: 1 and 10. I would to loop for i=first and i<last this thing that I append on a div named "result". But at the moment nothing happens. Neither errors in the console.


$(document).ready(function(){
  $("#btn").click(function(){
    var name = $("#name").val();
    var type = $("#type").val();
    var first = $("#first").val();
    var last = $("#last").val();
    for(i=first; i<last; i++){
        $("#result").append("<div class='myClass'><h3>" + name + "</h3><h3>" + type + "</h3><h3>" + i + "</h3></div>");
    }

    });

  });
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: andrea