HI there, I was wondering if anybody can advise.
I am trying to build an unordered list with a few items in a page, and I want this list to be created and displyaed dynamically.
So I create an array of strings and then through jquery I want this to slowly appear at page load (I have seen this test advertised on a website somewhere and I thought I give it a go but I am not 100% how to proceed)
Here's the html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<link rel = "stylesheet" type = "text/css" href = "style.css">
<script type = "text/javascript" src = "script.js"></script>
</head>
<body>
<div id = "cities">
</div>
</body>
</html>
and the css is here:
#cities
{
background-color:green;
width:100%;
height: 400px;
borde: 1px solid blue;
}
Now to the script, I have done just a bit of it because I am not too sure how to go about it:
var city_arr = new Array(4) {"London", "Madrid", "Leeds", "Barcelona"};
var cities_div = document.getElementById("cities");
$my_cities = $("#" + city_arr);
var index = 0;
function getCities(){
$("#cities").html("<ul><li>"$my_cities[index]...)
}...
Now, I wouldn't want to get the code from anyboy, rather I would like to try to write some code myself, and learn something, but I was hoping somebody can give me some good suggestions as to how to proceed.
After I created the array in the script I was hoping I could display each item in the array in a formatted bullet list, perhaps creating the list using the html()
method, but I have soon realized that I can't create multiple <li>
tags with the same method...uhm...
thanks