This problem is about passing parameters between functions(define neighbour elements and acess these elements)
Here is some HTML
<ul class="listing">
<li><a href="imgs/eli.jpg" id="1" class="lightbox" onclick="defineNeighbours(this.id);"><img src="thumbs/eli_t.jpg" width="150" height="100" class="images" /></a></li>
<li><a href="imgs/ggallin.jpg" id="2" class="lightbox" onclick="defineNeighbours(this.id);"><img src="thumbs/ggallin_t.jpg" width="150" height="100" class="images" /></a></li>
<li><a href="imgs/jontarata.jpg" id="3" class="lightbox" onclick="defineNeighbours(this.id);"><img src="thumbs/jontarata_t.jpg" width="150" height="100" class="images" /></a></li>
</ul>
This Javascript function is about getting the neighbours(next and previous) of given element.
function defineNeighbours(id){
var nextimages = document.getElementById(++id);
var backvalue = --id;
var previmage = document.getElementById(--id);
alert(nextimages);
alert(previmage);
}
Then I need to pass the nextimages and previmage variables to the next function. This function should acess these elements.
function nextimage(nextimages){
$('<img src="nextimages"/>')
}