javascript - jQuery var background map issue -


var set = "1";  var settings = {      images: {         'images/set' + set + '/bg01.jpg': 'center',         'images/set' + set + '/bg02.jpg': 'center',         'images/set' + set + '/bg03.jpg': 'center',         'images/set' + set + '/bg04.jpg': 'center',         'images/set' + set + '/bg05.jpg': 'center'     },     delay: 6000 }; 

i think i'm doing wrong + set +. needs outcome "set1", can adjust it, doesn't work.

searched hour solution this. please me out this.

if want assign properties images object based on value of variable, should use bracket notation reference properties. try this:

var set = "1"; var settings = {             images: {},             delay: 6000 }; settings.images['images/set' + set + '/bg01.jpg'] = 'center'; settings.images['images/set' + set + '/bg02.jpg'] = 'center'; settings.images['images/set' + set + '/bg03.jpg'] = 'center'; 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -