Solved

CheckBox inside a DIV

Posted on 2011-03-06
2
487 Views
Last Modified: 2013-11-05
I have a simple div that has 2 checkboxes inside. therefore when I select a checkbox inside the div I want to call a function and do something. ie.

<div id='wheels'>
    <asp:CheckBox ID="hotwheels" CssClass='WheelsCSS' Text="HOT" runat="server"/>
    <asp:CheckBox ID="Littlewheels" CssClass='WheelsCSS' Text="LITTLE" runat="server"/>
</div>

//Never gets fired but no syntax error I'm I missing something?
$('#wheels > input.checkbox').click(function () {
         //do something                
            });
0
Comment
Question by:7of9121098
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 50 total points
ID: 35049699
You may use :

        $('#wheels').find("input[type='checkbox']").click(function () {
            alert("you click " + $(this).attr("ID"));
        });

Open in new window


Test page :



<%@ Page Title="Page d'accueil" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $('#wheels').find("input[type='checkbox']").click(function () {
            alert("you click " + $(this).attr("id"));
        });
    });
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div id='wheels'>
    <asp:CheckBox ID="hotwheels" CssClass='WheelsCSS' Text="HOT" runat="server"/>
    <asp:CheckBox ID="Littlewheels" CssClass='WheelsCSS' Text="LITTLE" runat="server"/>
</div>
</asp:Content>

Open in new window

0
 

Author Closing Comment

by:7of9121098
ID: 35053263
Excellent! Thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now