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

android - Pass an Serializable object in AIDL -

php - Improving script execution time -

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