Image does not change when i enter the URL


#1

Hi guys,

The top and bottom text change fine, but when i try and change the image url the image stays the same. Below is a copy of my code. Any help would be appreciated.

Thanks!!



var main = function() {
$('#top-text').keyup(function() {
  var top = $(this).val();
  $('.top-caption').text(top);
});
  $('#bottom-text').keyup(function() {
  var bottom = $(this).val();
  $('.bottom-caption').text(bottom);
  });
  $('#img-url').keyup(function() {
  var url = $(this).val();
    $('.img').attr('src',url);
  });
};
  
 
$(document).ready(main);



#2

Hi @cliffod2015,

If you have this, with the id specified as "image-url" in your index.html file …

<input id="image-url" type="text" class="form-control">

… then you need to have '#image-url' in the app.js file …

$('#image-url').keyup(function() {

You have …

$('#img-url').keyup(function() {

#3

Hi @appylpye thanks for your reply that worked! Good stuff !! :grin:


#4