javascript - Change divs background image using JQuery in a loop doesn't work on Google Chrome -


in application have loop change background image of 2 divs. code :

for (var = 0; < length; i++) {    $("div_" + (i + 1)).css("background-image", "../imagefile.png");               } 

works on internet explorer, edge, firefox not on google chrome. on google chrome, changes last image.

thanks.

hi again, quick responses chiristian , nascheez! apologize, didn't write code. in original code, put right structure. , works in other browsers. on google chrome , opera, shows image of last div.

the original code :

function testfunction() {         $.ajax({             type: 'post',             url: '@url.action("someaction", "somecontroller")',             data: {              },             async:false,             datatype: 'json',             success: function(datapieces) {                  //i pieces whitout error!                 config.allpieces = datapieces;                  (var = 0; < datapieces.length; i++) {                     $("#div_" + (i + 1)).css("background-image", datapieces[i].imagepath);                 }             },             error: function(error) {                 alert("9- la transaction rencontré une erreur. \n" + error.message);             }         });     } 

i found solution, change image event triggers event. problem comes speed of google chrome. other browsers don't have enough time refresh google chrome , opera speed enough. result, changed method, added parameter avoid calling of other event.

many time.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -