I saw many questions where people were hiding/revealing images using jQuery, but I don't have jQuery installed and I would far prefer to use Html/css?
Is there a way to reveal an image when clicking on a button without using any javascript?
As @Gnuey said, it's easy to install jQuery just by referencing it from a host. Both google and Microsoft host jQuery, but most people use google. I recommend you check his comment for more info.
Actually, @Dipesh Parmar you can make this work in pure css, but you need a but of a work around:
Give the image an id, then make the button go to that id:
<a href="/#revealonclick"><button>Click to reveal image</button></a>
<img alt="" id="revealonclick" src="/image/pic.png">
Then in the CSS of the image:
#revealonclick{
display: none;
}
#revealonclick:target{
display: inline;
}
Yep. It's possible. CSS3 is awesome.
You can use checkboxes to toggle click.
HTML
<input type="checkbox" id="toggle">
<label for="toggle">Click me!</label>
<img src="http://image.shutterstock.com/display_pic_with_logo/232318/232318,1264892711,1/stock-photo-sleeping-pug-puppy-45602341.jpg" alt="" />
CSS
img{display:none;}
input[type=checkbox]:checked ~ img {
display:block;
}
You don't need jQuery to do that. Just use pure Javascript without any libraries.
There are some CSS events, most common is :hover, but in your case :active is the closest one. However. there are no good way of doing this with pure CSS. Here is a link too what you can do with only CSS:
You can use the basic form of JavaScript as follows:(if you seriously are against installing jQuery)
function toggleImage() {
var imgId = document.getElementById('image');
imgId.style.visibility = (imgId.style.visibility === "hidden" || imgId.style.visibility === "") ? "visible" : "hidden";
}
Where the HTML is
<img id="image" src="http://i458.photobucket.com/albums/qq305/Ellerwind1982/souleater5.jpg" />
<button id="sth" onclick="javascript: toggleImage();">Hi</button>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>It's not really installing, actually. You are referencing a jQuery file which happens to be hosted online by Google.