Solved

CheckBox inside a DIV

Posted on 2011-03-06
2
490 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nvd3.js license 3 836
2 select 2 boxes on same page - 2nd one not work 8 721
simple JavaScript webpage doesn't work 9 235
Problem to run jar file 4 150
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
As a business owner, there are many things that keep you up at night. Profit margins, employee retention, human resource protocols, whether your product or service will remain competitive. When you own or manage a technology company that operates la…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

778 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