Apologies, if this comes through to the list twice (I waited a few
hours before pushing again).

Update. Here's the beautiful hunk of script that I have at the moment,
but I'm wanting to add the class to the label based on whether it's
associated input element is selected.

$(document).ready(function() {
        $('div#searchLabels input').each(function(index) {
                var $thisLink = $(this);
                $thisLink.attr({
                        'class': 'buttonInputs'
                });
        });
        $('div#searchLabels label').each(function(index) {
                var $thisLink = $(this);
                $thisLink.attr({
                        'class': 'buttonLabels'
                });
        });
        $('div#searchLabels label#labelEntireSite').addClass("selected");
        $('div#searchLabels label#labelEntireSite').click(function() {
                $(this).addClass("selected");
                $('div#searchLabels 
label#labelRecipesCat').removeClass("selected");
        });
        $('div#searchLabels label#labelRecipesCat').click(function() {
                $(this).addClass("selected");
                $('div#searchLabels 
label#labelEntireSite').removeClass("selected");
        });
});

On Nov 13, 12:57 pm, sperks <[EMAIL PROTECTED]> wrote:
> I have some formatting I want to add to a couple of radio buttons.
>
> I'm wanting to hide the actual radio buttons and only show the labels
> which I want to format differently depending on whether they're
> related radio button is selected or not.
>
> HTML:
> <div id="searchLabels">
>         <input type="radio" value="" id="entireSite" selected="selected"
> name="cat">
>         <label for="entireSite" class="selected" id="labelEntireSite">Entire
> Site</label>
>         <input type="radio" value="recipes" id="recipesCat" name="cat">
>         <label for="recipesCat" id="labelRecipesCat">Recipes</label>
> </div>
>
> If I click on the recipes label (id="recipesCat") I want to change
> it's class. I've been thinking along the lines of associating it via
> it's corresponding input element becoming selected
> ([EMAIL PROTECTED]"selected"]), but I'm pretty new to jQuery and any
> help getting me in the right direction would be great.
>
> Thanks
> Steve

Reply via email to