jquery change onclick -
Hello I'm trying to create an on-line photoblog So for this idea a picture and two elements have to load the next and previous image in the album with an onclined event. I have created a function for this, but it only works once. If you click on the previous or next button, the onclick is executed, but the onclick properties are not changed and a simple warning box tells me that the code has not been executed for a second time.
I'm sorry to have a Dutch language photo in my code photos!
My HTML looks like this
& lt; Div id = "fotolarge" & gt; & Lt; Span class = "arrow right" & gt; & Lt; / Span & gt; & Lt; Span class = "arrow arrowleft" & gt; & Lt; / Span & gt; & Lt; Span id = "fotoloading" & gt; & Lt; / Span & gt; & Lt; Img id = "foto" /> & Lt; / Div & gt; My JavaScript looks like this
function load photo (source) {$ ("#bootrolling"). CSS ("z-index", "3"); $ Current Index = jQuery.inArray (src, $ photoArray); // Next image $ next index = $ current index + 1; If ($ next index & lt; $ photoArrayLength) {$ (".rightright") Ether ("onclic", "load photo" ("$$ photoar [[next index] +" '' ');} and {$ (".arrowite"). Et ("onclic", "load photo" ("$" $ $ [$] + "')"} //} previous image $ previous index = $ current index - 1; if ($ previous index> = 0) {$ (".rowrow"). Attr (" Onclick "," loadphoto "(" + $ photoArray [$ previousindex] + "')');} and {$ (" .rowrow "). Etter (" onclick "," load photo "($" photo $ $ photoArrayLength -1] + "')"};} load loader = new image loader (src); Loader.loadEvent = function (url, image) {$ ("#boolocation"). Css ("z-index", "2" ); $ ("# Photo") replaceWith (image). Css ("display", "block"); calcmiddle ();} Loader.load ();} variable $ photoArray and $ photoArrayLength global variables $ PhotArray keeps a list of sources of images. Imageloader is not a problem, because it does not work either part is comment.
I hope someone will decide how to do this Fix. I have tried this jquery .click ()
$ ("rightright"). Click (function () {loadPhoto ($ photoArray [0]);}); Then it works partially. This makes loadPhoto in the infinite loop to execute;
You're better at using click events to tell which direction you're heading (1 or 1) And keep track of the current status instead of rewriting click event
Comments
Post a Comment