0

In my rails application I changed navbar icons using jquery, When the images are precompiled the image name is like 'nav1_completed-0d81e4b2c254459e456870960fa480c2.png', How do I load this image using jquery?

$('#nav1').find('img').attr('src', "/assets/nav1_completed.png");

When I load the above function it doesn't load image since the names are different, how to load images using jquery?

M.R
  • 610
  • 2
  • 10
  • 34

1 Answers1

0

You can try as below to check if your image name starts with nav1

$('#nav1').find("img[name^='nav1']").attr('src', "/assets/nav1_completed.png");
Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200