Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CheckBox inside a DIV

Posted on 2011-03-06
2
Medium Priority
?
498 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 200 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know there are services out there that can turn an Instagram feed into an RSS feed? I found some interesting exclusive Instagram content which I wanted to follow without signing up for yet another social media account. RSS to the rescue!
Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

963 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