I've spent the past hour trying to figure this out and I can't seem to get it right. I've only just started learning jQuery but I feel I'm getting close to a solution for this problem of mine.
I have two divs.
HTML
<div class="fl person">
<input type="hidden" name="userSaved" id="userSaved" value="1" />
<img src="..." class="circle-mask" />
</div>
<div class="fl person">
<input type="hidden" name="userSaved" id="userSaved" value="2" />
<img src="..." class="circle-mask" />
</div>
I want to be able to get the hidden value (there's a form outside of all of this, I just didn't include it as it would just take up more room) from which ever div/image is clicked. When an image is clicked it hides that div. My jQuery for the value is quite off. I've had it so it gets the value but only from the first div, I can't seem to get it so that it displays the value of the hidden input from which ever div is clicked.
jQuery
<script>
$("div.person img").click(function () {
$(this).hide(500, function () {
var $hidden = $('input#userSaved');
alert($hidden.val());
$(this).parent("div").empty();
$(".main_page").appendTo("div.main_page").addClass("fl person");
});
});
</script>
Also, how do I access $hidden outside of the function?