1

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">

    </div>

EDIT:::::::::::::::::::::::

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

0

1 Answer 1

2

try this

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

add this at below

$("#LayoutDiv1").children("img").attr("src",mainImg);
Sign up to request clarification or add additional context in comments.

3 Comments

No, I don't need to replace the html code with the new string. I need to use the string later on in my js code to find a different img link. the problem is the value isn't changing with .replace
have you use console.log(mainImg) or console.log($("#LayoutDiv1").children("img").attr("src")) to see can get the src or not ?
I used an alert function that fired when I clicked on the image. However it seems to suddenly be working for some reason when it wasn't before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.