user1257680
user1257680

Reputation: 21

On-click jquery mobile

I need some sort on onclick function for my jquery mobile/php website. The following on-click wont work...

    <div data-role="fieldcontain">
        <fieldset data-role="controlgroup">
_END;
$int = 0;
foreach (array_slice($list,1) as $value) {
    echo <<<_END
        <input type="checkbox" name="checkbox-$int" id="checkbox-$int" class="custom" />
        <label for="checkbox-$int">$value</label>   
    _END;
    $int = $int+1;
}
echo <<<_END
        </fieldset>
        <script type="text/javascript" > 
            $(".checkbox-1").click(function(){
                alert('clicked!');
            });
        </script>
    </div>
_END;

Upvotes: 0

Views: 149

Answers (1)

greaterweb
greaterweb

Reputation: 571

Your jQuery is using a class selector, you need to update to it used an ID selector to match the output.

Replace

$(".checkbox-1").click 

with

$("#checkbox-1").click

Upvotes: 4

Related Questions