Thursday, July 2, 2009

[jQuery] Fire event

Hi there,

i'am new to jquery so my question is maybe too easy for you? ;)

I got the following: 3 Radiobuttons which each i added a click event
that shows up a new div with some information about the value of this
radio button. This works fine.
Now when i load the page and passing a PHP variable to the script one
radio button is checked by default. This also works but the div with
the information doesn't appear.

Is there a way to check which button is selected on $(document).ready
and then fireing the event which is attached to this button?

Here is a code snipped of my first jquery script:

$(document).ready(function(){

$(".infotext").hide(); // onload hide the infofield

// for each button hide the infofield and fade in just the one i need
- this works :)
$("#btn_1").click(function(){
$(".infotext").hide();
$("#info1").fadeIn("slow");
});
$("#btn_2").click(function(){
$(".infotext").hide();
$("#info2").fadeIn("slow");
});
$("#btn_3").click(function(){
$(".infotext").hide();
$("#info3").fadeIn("slow");
});
});


Regards,
qualle

No comments: