Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery make new variable with dynamic name

var vars = {};
var newCount = 0;

$('.hello').click(function(){
    newCount++;
    vars['hello' + newCount] = '<p>Hello World</p>';
    console.log( JSON.stringify(vars) );
}); 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #variable #dynamic
ADD COMMENT
Topic
Name
9+8 =