Adding css class to all the image elements is a lengthy task and I was wondering if we can add css class to all the images by default. Something like this:
img {class:'hover-share-buttons';}
but the technique doesn't seem to work. Is there something wrong with this code or am I doing it completely wrong? Normal css is easy to add but can we add an class ?
An answer will be much appreciated. I am trying this on weebly http://geniusknight.weebly.com. The class attribute comes from an external js file (addthis lab js) and sorry about putting the .img there, it was my bad but still it doesn't work. You see I have no css for that because the class attribute is coming from addthis script.
You could just use:
img {
// Your styles for all images
}
However, if you want to add default class to all images, you need to use javascript:
var i, images = document.getElementsByTagName("img");
for(i = 0; i < images.length; i++) {
images[i].className += " hover-share-buttons";
}
or easier if you're able to use jQuery:
$("img").addClass("hover-share-buttons");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With