I’m trying to add button and click listener to every save span on a page. I do:
$("#save").button().click(function(){
currentSlide++;
loadPage();
}
loadPage clears my dialog box and loads the next slide into the box. If I don’t add that code to the load page function, only the first save button is assigned the button and click listener. Why do i need to assign the listener every time. Shouldn’t jQuery assign the button and click listener to all #save?
All the slides are stored on the page. Load page takes the hidden content and appends it to the dialog box.
Id must be unique for all elements!!!
You have defined an ID selector for you bind to click function. There should only be one ID for each element therefor
$('#save')will only bind to one element (the first one). If you want to bind to all spans used in this way then add a class to each span and reference it this way, using a class selector