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>

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);

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"/>')
7 Years
Discussion Span
Last Post by Airshow

If, as the code in nextImage implies, you propose to use jQuery, then the door is open to doing this far more efficiently than with onclick handlers in the HTML.

For example, $items = $("li.lightbox a") selects all the links in the unordered list.

You then have a jQuery object which can be enquired to discover for any link, the previous and next links for whatever purpose you have in mind.

Alternatively, install something ready-written; see here for some ideas.


Edited by Airshow: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.