Collin McCabe Collin McCabe - 1 year ago 62
HTML Question

.attr.replace() not working in javascript

For some reason I can't get my code to work

var mainImg = $("#LayoutDiv1").children("img").attr("src").replace("myFull", "mytinythumbs");

It draws from this and it isn't a problem with the setup as other functions work just fine, for some reason it doesn't replace myFull instead it just leaves it there.

<div id="LayoutDiv1">
<a href="#" id="btn-back"><i class="fa fa-angle-left"></i></a>
<a href="#" id="btn-forward"><i class="fa fa-angle-right"></i></a>
<img id="pusher" class="resize" src="../images/myFull/Young_Diego.jpg" alt="page1">



The code suddenly decided to work...not sure what the error was before

Answer Source

try this

var mainImg = $("#LayoutDiv1").children("img").attr("src").replace("myFull", "mytinythumbs");

add this at below

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download