JavaScript Dynamic Variable Names

前端 未结 6 847
感动是毒
感动是毒 2020-11-27 21:23

Ok so I want to create variables as a user clicks threw the code every click adds a new variable. I am currently using jquery and javascript I can\'t do it server side this

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 21:47

    var newCount = 0;
    $('#btn').click(function(){
    
        newCount++;
        $('#hello').html('hello' + newCount);
    }); 
    

    jsfiddle

提交回复
热议问题