I've just started learning Jquery but the examples aren't helping me much...
Now whats happening with the following code is that I have 4 forms that I switch between using a link for each. But what I can't figure out is how to get variable "postOptionSelected" in the first function to pass to the other functions to display even more user options. I realize the variable is not is scope but how do I do this?
$(document).ready(function(){
$("#postOptions ul li a").click(function(event){
var postOptionSelected = $(this).parent("li").attr("class").substr(11);
$("form#post"+postOptionSelected).css('display', 'block');
$("form.postForm:not(#post"+postOptionSelected+")").css('display', 'none');
event.preventDefault();
});
$("form#post"+postOptionSelected+" div#postMore"+postOptionSelected+" a").click(function(event){
$("form#post"+postOptionSelected+" div#postMore"+postOptionSelected).css('display', 'none');
$("form#post"+postOptionSelected+" div#postLess"+postOptionSelected).css('display', 'block');
$("form#post"+postOptionSelected+" div#postView"+postOptionSelected).css('display', 'block');
event.preventDefault();
});
$("form#post"+postOptionSelected+" div#postLess"+postOptionSelected+" a").click(function(event){
$("form#post"+postOptionSelected+" div#postLess"+postOptionSelected).css('display', 'none');
$("form#post"+postOptionSelected+" div#postMore"+postOptionSelected).css('display', 'block');
$("form#post"+postOptionSelected+" div#postView"+postOptionSelected).css('display', 'none');
event.preventDefault();
});
});