Ok here is my question i hope its something easy. I have CMS that generates images from whatever url I put with its corresponding syntax. Well I want to add a Lightbox to does images but instead of going into the CMS to find how where it outputs the actual code that appears i was thinking of using JS to add an attribute of rel="lightbox" to links within a certain div that have a class of media.
Example:
Here is a link to an image that might be found on my page
[HTML]<a href="images/blah.jpg" target="_self" class="media">< img src="images/blah.jpg" /></a>[/HTML]
One way I was thinking of doing it was the function "replace". something like this
and then this code to find the class which im not sure if it will work.
Can someone please help me put this together. My final link should output as.
[HTML]<a href="images/blah.jpg" target="_self" class="media" rel="lightbox"> <img src="images/blah.jpg" /></a>[/HTML]
Example:
Here is a link to an image that might be found on my page
[HTML]<a href="images/blah.jpg" target="_self" class="media">< img src="images/blah.jpg" /></a>[/HTML]
One way I was thinking of doing it was the function "replace". something like this
Code:
javascript:document.body.innerHTML.replace("Index","67890");
Code:
//Create an array
var allPageTags = new Array();
function doSomethingWithClasses(theClass) {
//Populate the array with all the page tags
var allPageTags=document.getElementsByTagName("*");
//Cycle through the tags using a for loop
for (i=0; i<allPageTags.length; i++) {
//Pick out the tags with our class name
if (allPageTags[i].className==theClass) {
//Manipulate this in whatever way you want
allPageTags[i].style.display='none';
}
}
}
[HTML]<a href="images/blah.jpg" target="_self" class="media" rel="lightbox"> <img src="images/blah.jpg" /></a>[/HTML]
Comment