javascript - jQuery - replacing div background image from URL -


i'm trying replace div background in several divs label element (typed url) , while code works, won't push through $('#urlimage').

jquery:

$(document).ready(function(){ $('.first, .second, .third').append("");   $('#urlimage').change(function(){     $('.first, .second, .third').css('background-image', $('#urlimage').val());   }); }) 

html

<input type="text" id="urlimage" placeholder="type image url">  <div class="first"> </div> <div class="second"> </div> <div class="third"> </div> 

basically need whatever typed loaded background image.

thanks suggestions.

let try

$(document).ready(function(){   $('#urlimage>div').each(function(){     $(this).css('background-image', $('#urlimage').val());   }); }) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -