« Return to Thread: Fire event
Re: Fire event
Hi,
thanks for the reply! Didn't know trick with if ($(<selector>).is
(<something>)) { ... }
This worked fine for me thanks!
I know the "each" function but i have different actions on each
element so i can not use this for my case. But thanks for the hint!
Cheers,
qualle
On Jul 2, 9:41 pm, Charlie <charlie...@...> wrote:
> here's a quick start to get you going. Without seeing some markup to build a relationship between the button and the #info container would need to splice() to pull number off the button ID and splice the #info to create function to open correct one. Some markup would help as there are a number of easier ways to do this depending on container configuration
> Add a class .infoButton to your buttons unless you already have a class just for them. You can do this with ID's but as with CSS it's easier to use classes in many instances with jQuery. Following only works if *only* one of them will be checked
> $(".infoButton").each(function () {
> if ($(this).is(':checked')) {
> $(".infotext").hide();
> //// Open appropriate #info .....seeing markup here will help, or use splice to filter ID's. Adding a class to the #info's will probably help also
>
> });pascal.naujoks@...: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
« Return to Thread: Fire event
| Free embeddable forum powered by Nabble | Forum Help |