Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CheckBox inside a DIV

Posted on 2011-03-06
2
Medium Priority
?
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Read on to get a few ideas on how to promote your next corporate event.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 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