I have function like this which enables gallery by his ID:
document.getElementById('galleryID').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
bg.Gallery(links, options);
};
But the problem is when I have multiple gallerys in one document:
id="gallery01"
, id="gallery02"
, id="gallery03"
... up to id="gallery11"
.
Now I multiplayed code of gallery script 11 times with different ID:
document.getElementById('gallery01').onclick = function (event) { ...
document.getElementById('gallery02').onclick = function (event) { ...
document.getElementById('gallery03').onclick = function (event) { ...
up to ...
document.getElementById('gallery11').onclick = function (event) { ...
I wish to have one JS function not 11. How can I do this ?
I would like to use regular expressions but my combinations didn't work. I think it would be very nice solution if it could be done like this - using regullar exp in place where is 'galleryID'
.