0

I was wondering why my code isn't working, normally the first image should be displayed on my screen but I don't know what it might be, my css is prefixed, and should normally work with jquery.

<script>

(document).ready(function(){
    var photoArray["p/2012/03/73133.jpg","p/2013/03/73096", "p/2013/03/72940", "p/2013/03/72922", "p/2013/03/72913","p/2013/03/72492"]
    var url = "http://weerfoto.buienradar.nl/"

    $("gallery").html("<div id='frame'><img /> </div>" + "<ul class='fotolist> </ul>")
    $("#frame img").attr("src", url + photoArray[0]);
});
</script>
1
  • Not sure if this is relevant but you are missing a ' from the class class='fotolist... Commented May 15, 2013 at 13:04

2 Answers 2

1

Just fixing validation errors:

$(document).ready(function(){
    var photoArray = ["p/2012/03/73133.jpg","p/2013/03/73096", "p/2013/03/72940", "p/2013/03/72922", "p/2013/03/72913","p/2013/03/72492"];
    var url = "http://weerfoto.buienradar.nl/";

    $(".gallery").html("<div id='frame'><img /></div>" + "<ul class='fotolist'></ul>");
    $("#frame img").attr("src", url + photoArray[0]);
});

But a better approach might be:

var photoArray = ['p/2012/03/73133.jpg','p/2013/03/73096','p/2013/03/72940','p/2013/03/72922','p/2013/03/72913','p/2013/03/72492'];

$(document).ready(function(){    
    $('.gallery').html('<div id="frame"><img src="http://weerfoto.buienradar.nl/'+ photoArray[0] +'" /> </div><ul class="fotolist"> </ul>');
});

I assumed gallery was a class here.

Sign up to request clarification or add additional context in comments.

1 Comment

yes indeed, it made it more readable and less complex, thank you. i think there is something with my program that i'm using not my syntax. However i still learned one or two things thanks to you.
1

Define array like this.

var photoArray = new Array("p/2012/03/73133.jpg","p/2013/03/73096", "p/2013/03/72940", "p/2013/03/72922", "p/2013/03/72913","p/2013/03/72492");

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.