Reputation: 751
I'm having difficulty in correcting the syntax error for image swap. I would appreciate if you can help me out as below?
function swap(i, s)
{
var d = document.images;
d ? d[i].src=s : null;
}
Upvotes: 0
Views: 70
Reputation: 859
I think you want something like this
function swap(i, s) {
var d = document.images;
if (i >= 0 && i < d.length) {
d[i].src = s;
}
}
Upvotes: 1