Add a new block, how to increase the number displayed in the content

the function to be done is

at first, only one block content is displayed 1

then when you press the add button, the same block will be added and the number displayed in the block content will increase by 2

.

continue to add 3, 4, 5.

the problem encountered is that I don"t know how to increase the number displayed in the block after adding the block. Please help me to see how to change it

.

Source code:

$(".container").on("click", ".addNewBlock", function(e) {
    var content = [];
   
    //
    var num = 1 ;
  
    content.push("<div>"+num+"</div>")
    $(this).parents(".container").append(content.join(""));
  
});
May.06,2021

var num = 1 ;
$(".container").on('click', '.addNewBlock', function(e) {
    var content = [];
   
    //
    num +=1;
  
    content.push('<div>'+num+'</div>')
    $(this).parents('.container').append(content.join(""));
  
});


$(".container").on('click', '.addNewBlock', function(e) {
    var content = [];
    content.push('<div>'+(content.length+1)+'</div>')
    $(this).parents('.container').append(content.join(""));
  
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5de09-45760.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5de09-45760.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?