Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:54:15+00:00 2026-06-08T03:54:15+00:00

$(#btn).button().click(function() { $(#textinput).css(‘color’,function(clr) { if ($(#textinput).css(‘color’) == ‘#000000’) return ‘#ff0000’; else return ‘#000000’; });

  • 0
$("#btn").button().click(function() {
    $("#textinput").css('color',function(clr) {
        if ($("#textinput").css('color') == '#000000')
            return '#ff0000';
        else
            return '#000000';
    });
});

for some reason I cant toggle between the colors in input text. the .css docs of jQuery states the following:

Different browsers may return CSS color values that are logically but not textually equal, e.g., #FFF, #ffffff, and rgb(255,255,255).

in general, how can i get the property value of UI object (css values are constant?) ?

thnx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:54:16+00:00Added an answer on June 8, 2026 at 3:54 am

    I would create a class .white and a class .black and use .addClass() and .removeClass(). A html element can have multiple classes set

    $("#btn").button().click(function() { 
        if ($("#textinput").hasClass("white"))
        {
            $("#textinput").removeClass("white").addClass("black");
        }
        else {
            $("#textinput").removeClass("black").addClass("white");
        }
    }); 
    

    I think someone will post a more elegant solution to this, because I think this is too much code for a simple task like this.

    update:
    Use toggleClass instead: http://api.jquery.com/toggleClass/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function: $(button.btn-info).click(function() { var id=this.id; }); So, and I have to
I disable my jqueryui button in its click event like this $('#btn').button().click(function(){ $(this).button('disable'); });
<div class=form-actions> <button class=btn btn-primary id=btn-next>Next</button> <button type=reset class=btn>Reset</button> </div> $(#btn-next).click(function(event) { $('#tab li.active').next().find('a[data-toggle=tab]').click();
I'm creating some 50 button dynamically. Text is getting set as followed: btn.Text=result.Rows[i]["Col1"].ToString()+"\n"+result.Rows[i]["Col2"].ToString() +"\n"+result.Rows[i]["Col3"].ToString();
This is my code : var data = []; $(#btn).click(function(){ total++; data.push({ id :
I want to click a button, show a loader image, execute a time-consuming function,
Here is my code: $('.button').click(function() { $(this).addClass('clicked'); $('.button').not(this).removeClass('clicked') .addClass('not_clicked'); $('#tool_window,#wrapper').not('#work_area').not('.button').addClass('outside'); }); $('.outside').click(function() { $('.clicked').removeClass('clicked');
public View getView(int position, View convertView, ViewGroup parent) { Button btn; if (convertView ==
How can I remove/overshadow .ui-btn-active class on an active button in my navigation bar?
If we add event listener to a button in java like this : btn.setOnClickListener(new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.