I have this thumbnail list and would like push the image paths (sources) into an array: tn_array
<ul id="thumbnails">
<li><img src="somepath/tn/004.jpg" alt="fourth caption" /></a></li>
<li><img src="somepath/tn/005.jpg" alt="fifth caption" /></a></li>
<li><img src="somepath/tn/006.jpg" alt="sixth caption" /></a></li>
</ul>
You can loop through ever
img
element:You can create the array of src attributes more directly using
map()
:Edit:
tn_array
is an object here rather than a strict Javascript array but it will act as an array. For example, this is legal code:You can however call
get()
, which will make it a strict array:How do you tell the difference? Call:
The first version will be:
The second: