When you click on “Hide Information”, I would like to change the text from “Hide Information” to “Show Information” and also change the icon: https://cdn4.iconfinder.com/data/icons/seo-and-data/500/view-content-window-16.png.
When the text is clicked again, it should change from “Show Information” to “Hide Information”.
Please remember that when you show information the text “teststests” shall display. If you want to hide “teststests” you click on the “Hide Information”.
I don’t know how to do it.
Thanks!
$(document).ready(function(){
$("div#test").click(function(){
$("#test2").toggle();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="test2" style="display:none">
teststests
</div>
<div id="test">
<img src="https://cdn0.iconfinder.com/data/icons/octicons/1024/eye-16.png" /> Show Information
</div>
4
Answers
check this fiddle
code
HTML
FIDDLE
HTML:
jQuery:
CSS:
This is assuming you are using an font-awesome for your icon and jquery for your javascript
your markup
Your jquery
That should do
Cheers.
Exactly what you want:
js part:
You just need to change a little in the html like adding an ID:
Check http://jsfiddle.net/2pys32qj/