I am using this probably ugly javascript to show a text box (in a li tag plus its label) if a checkbox is checked.
$("#li-2-21").css("display","none");
$("#Languages-spoken-and-understood-8").click(function(){
if ($("#Languages-spoken-and-understood-8").is(":checked"))
{
$("#li-2-21").show("fast");
}
else
{
$("#li-2-21").hide("fast");
}
});
That works fine but it doesn't work if a page is loaded and the checkbox is already checked because the #li-2-21 gets automatically hidden.
Do I need to create a function that reads the state of the checkbox? Or is there a simpler way?
Oh and also feel free to shorten that ugly code, I guess there's a shorter way to achieve my goal? Thanks so much for your help!