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 7688791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:00:21+00:00 2026-05-31T20:00:21+00:00

I have an html special character I want to toggle off and on like

  • 0

I have an html special character I want to toggle off and on like a check box. In this instance, it’s a star: ☆ that can become filled in: ★.

I want to check the state of the star when it is clicked.

$(".action_table_star").click(function() {
    if ($(this).html() == "★") {
        $(this).html("☆");
        $(this).css('color', 'white');
    } else {
        $(this).html("★");
        $(this).css('color', 'rgb(255,165,0)');
    }
});

This doesn’t work though because $(this).html() is never equal to “&#9733”. How can I rewrite this if statement to I guess decode the html special character and check it’s “state”?

  • 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-05-31T20:00:23+00:00Added an answer on May 31, 2026 at 8:00 pm

    Improving on SpYk3HH’s suggestion, I would approach this by adding both stars to the document, one with display:none, and use jQuery to toggle them both on click.

    An additional benefit is that you can now style each star individually with CSS instead of jQuery, which is as it should be.

    HTML:

    <div class="action_star">
      <span class="star1">&#9733;</span>
      <span style="display:none" class="star2">&#9734;</span>
    </div>
    

    JS:

    $('.action_star').click(function() {
        $(this).find('.star1,.star2').toggle();
    });
    

    http://jsfiddle.net/cfjT5/1/

    Less code, more clear, more readable, much better.

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

Sidebar

Related Questions

I have a HTML that includes a Javascript file. This script contains a special
I have a string with special characters like this: äöüß& Now I want to
I have in the database words that include special character (in Spanish mostly, like
I have a webpage that uses the special character &#xFE3E in the HTML. In
I want to render for facebook bot special data. I have og.html.erb <!DOCTYPE html><html><head>
I have HTML like this: <article> <header> <hgroup> <h1>Wk 25 </h1> <h2>(18-06 tot 24-06)</h2>
I have HTML like this: <div> <a href=>sometext<img src=images/001.jpg /></a> <a href=>sometext<img src=images/002.jpg /></a>
I have some URL that contains special characters. For example: http://www.example.com/bléèàû.html If you type
I have HTML/jQuery like this: <select id=userlist name=userlist> <option value=''></option> <option value=ADJUDICATION>ADJUDICATION</option> <option value=ADMINISTRATIVE>ADMINISTRATIVE
Possible Duplicate: PHP: Convert special characters to HTML character codes I have a string

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.