Hi peeps, quick question. I am debugging a script in IE (it's producing errors and I suspect it might be down to the selectors) and I was
wondering if the below is correct.
Guven the following html

<div id="fruit_filter">
            <h1>Compare the Toyota range</h1>
                <div class="filter_checkboxes">
                    <h2>fruit type</h2>
                    <form id="first_filter">
                    <input type="checkbox" value="apples" name="fruit_type" checked="checked" id="apples" onClick="myFilter(this)"><label for="apples">Petrol</label><br><!-- apparently onchange isn't good and shouldn't be used with checkboxes-->
                    <input type="checkbox" value="bananas" name="fruit_type" checked="checked" id="bananas" onClick="myFilter(this)"><label for="bananas">Diesel</label><br>
                    <input type="checkbox" value="grapes" name="fruit_type" checked="checked" id="grapes" onClick="myFilter(this)"><label for="grapes">Hybrid</label><br>
                    </form>
                </div><!-- END OF filter_checkboxes -->
                <div class="filter_checkboxes">
                    <h2>Another type</h2>
                    <form id="second_filter">
                    <input type="checkbox" value="yellow" name="second_type" checked="checked" id="yellow" onClick="myFilter(this)"><label for="yellow">Manual</label><br>
                    <input type="checkbox" value="red" name="second_type" checked="checked" id="red" onClick="myFilter(this)"><label for="red">Automatic</label><br>
                    </form>
                </div><!-- END OF filter_checkboxes -->               
        </div><!-- END OF fruit_filter -->

I want to select the checked tickboxes in the jquery fragment below:

var $theFirstFilter = $("#fruit_filter").find("#first_filter input[type=checkbox]:checked");    
    var $theSecondFilter = $("#fruit_filter").find("#second_filter input[type=checkbox]:checked");

Is this the correct way to select the checked tickboxes? I mean is this syntax input[type=checkbox]:checked correct? I have seen this done in many different
ways and I am not sure what's good or bad.
cheers

Yes sir it appears to be correct :). See this page for more information.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.