Solved

Change CssClass JQuery ASP:Checkbox

Posted on 2014-03-05
4
295 Views
Last Modified: 2014-03-06
Hi all.

I have an ASP:Checkbox which I want to change the color of the text on it.

Now $('#<%=TermsCheckbox.ClientID%>').addClass('myclass');

is adding the class but the checkbox renders the text in a label using the same ID?

Any ideas how i can change this please?
0
Comment
Question by:flynny
  • 3
4 Comments
 
LVL 6

Expert Comment

by:M. Jayme Nagy
ID: 39906946
$("input[type='checkbox']").change(function(){
    if($(this).is(":checked")){
        $(this).parent().addClass("COLOR");
    }else{
        $(this).parent().removeClass("COLOR");  
    }
});

CSS
.COLOR{

}
0
 

Author Comment

by:flynny
ID: 39909200
but i need to do it for a particular check box not all.
0
 
LVL 6

Accepted Solution

by:
M. Jayme Nagy earned 500 total points
ID: 39909828
$("#id").click(function() {
    if (this.checked){
       $(this).closest('p').addClass('COLOR');
    } else {
       $(this).closest('p').removeClass('COLOR');
    }
});
0
 
LVL 6

Expert Comment

by:M. Jayme Nagy
ID: 39909869
thanks for the points

good luck on your adventures
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
Weekend adv creator 3 36
Angular - why isn't this ng-if isn't working? 4 42
javascript date picker in php while loop 5 46
Change color of pagination for twbs-pagination 3 22
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 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

19 Experts available now in Live!

Get 1:1 Help Now