What I want to do is to make the button value to be "1" if the section opened by pressing it is visible, and make it show "2" if the section is not visible. (visible/not visible - hidden/visible).
Here is my failed attempt that I think got the closest to the truth:
$(document).ready(function(){
$(".doc1").hide();
$(".doc").click(function(){
$(".doc1").slideToggle("fast");
if($('.doc1').is(':visible')) {
document.getElementById('doc').value = '1';
}
else
document.getElementById('doc').value = '2';
});
});
The value is stuck on "2" whether the section is opened (visible) or hidden (.hide).