2016-08-26, 07:34 PM
Hello guys I have been trying to work more on the postbit of my new upcoming theme however since I'm no expert in jQuery I think I have made some problem.
Aight so the thing I'm trying to do is to hide the author statistics under a div with a style of no display on document load and then I'm toogling it with a button.
But it works only for the first post i.e lemme provide a screenshot to clear it up.
As you can see in the image it works perfectly fine for the first post but in the second post when I click on the button it opens the authors stats instead of the one on which I click.
https://gyazo.com/c2181b7f79a08060f6094a8ab4e40001
Heres the code
And the script code
Thanks and regards
Aight so the thing I'm trying to do is to hide the author statistics under a div with a style of no display on document load and then I'm toogling it with a button.
But it works only for the first post i.e lemme provide a screenshot to clear it up.
As you can see in the image it works perfectly fine for the first post but in the second post when I click on the button it opens the authors stats instead of the one on which I click.
https://gyazo.com/c2181b7f79a08060f6094a8ab4e40001
Heres the code
<button onclick="toggle_visibility('foo');" class="reveal"> <i class="fa fa-sort-desc" aria-hidden="true"></i> </button>
<div id="foo" style="display: none;">
<div class="author_statistics">
{$post['user_details']}
</div>
</div>
And the script code
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
Thanks and regards