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
Post a Comment