Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to target a checkbox

Posted on 2012-04-03
2
Medium Priority
?
180 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
[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 53

Expert Comment

by:COBOLdinosaur
ID: 37803349
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 2000 total points
ID: 37804240
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

609 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