0

I am attempting to append an image source which does not reside on our server to reference and external server. Specifically this 4th line.

image of 4th line of code

I need this to reference an external server and not default to my default server. And suggestions?

$(document).ready(function() {
    $('#thumbs ul li').click(function() {
        var imgpath = $(this).attr('dir');
        $('#image').html('<img src=' + imgpath + '>');
    });
    $('.btn').click(function() {
        $('#thumbs').fadeIn(500);
        $('#image').animate({
            marginTop: '10px'
        }, 200);
        $(this).hide();
        $('#hide').fadeIn('slow');
    });
    $('#hide').click(function() {
        $('#thumbs').fadeOut(500, function() {
            $('#image').animate({
                marginTop: '50px'
            }, 200);
        });
        $(this).hide();
        $('#show').fadeIn('slow');
    });
});

2 Answers 2

1

The src attribute in your img tag is unquoted. Try this:

$('#image').html('<img src="' + imgpath + '">');
Sign up to request clarification or add additional context in comments.

Comments

0

I realized my mistake, I went in a different direction. Instead creating a new variable called "linkpath" and append the image source.

var imgpath = $(this).attr('dir');
var linkpath = "http://www.website.com";
$('#image').html('<img src=' + linkpath + / + imgpath + '>');

Comments

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.