Solved

Need to target a checkbox

Posted on 2012-04-03
2
173 Views
Last Modified: 2012-04-09
I have a click event that sets a checkbox to be checked, however it is targeting all the checkbox on the page with the same class.

I only want to target the checkbox that was clicked. Using Mootools.

var checkEmail = $$('input.user-address');
          $$(".content .addcheck").addEvent('click', function () {
              alert('test');
              checkEmail.set('checked',true);            
          });
0
Comment
Question by:yando18
2 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
You need to use a unique id for any checkbox that you want to target individually.  Any reference using a class name always targets every member of the class.

Cd&
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
What about : http://jsfiddle.net/hJbuD/
    $$(".content .addcheck").addEvent('click', function () {
        this.getPrevious('input.user-address').set('checked',true);             
    })¿

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

744 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

10 Experts available now in Live!

Get 1:1 Help Now