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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:28:13+00:00 2026-06-14T18:28:13+00:00

Look at these html and jQuery codes: <button>div</button> <button>span</button> <div class=fill>fill</div> <span class=fill>fill</span> <div

  • 0

Look at these html and jQuery codes:

<button>div</button>
<button>span</button>
<div class="fill">fill</div>
<span class="fill">fill</span>
<div class="fill">fill</div>
<span class="fill">fill</span>
<div class="fill">fill</div>
<span class="fill">fill</span>

(function() {
    $('button').click(function() {
        var buttonVal = $(this).text();

        $.expr[':'].fillClass = function(element) 
            { return $(element).attr('class') === buttonVal);};

        $('div:fillClass').css('opacity', '.2');
    });
})(jQuery);

when I click the button, it saves the value of button in buttonVal, but when I put the buttonVal in the return $(element).attr('class') === buttonVal does not work. I have changed the order of functions, but I do not know why it does not work.

  • 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-14T18:28:15+00:00Added an answer on June 14, 2026 at 6:28 pm

    First of all, I’m going to assume that you are trying to return a boolean value of whether the class of the element is equal to buttonVal. In that case, you need to surround the entire statement in parenthesis like this:

    return ($(element).attr('class') === buttonVal);
    

    However, there’s another issue. In your code, you have var buttonVal = $(this).text();. Therefore, buttonVal will have the value div or span depending on which button you clicked. None of the elements that you’ve given have the class div or span so therefore it won’t be true for anything.

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

Sidebar

Related Questions

Take a look at this simple HTML: <div id=wrap1> <iframe id=iframe1></iframe> </div> <div id=warp2>
Take a look at this example: http://www.extjs.com/deploy/dev/examples/multiselect/multiselect-demo.html On it, there are components rendered against
Assuming I have a JQuery object stored in $e obtained through this selector: var
I have the following starting HTML: <div id=modal ><div class=modal-window> <ul class=action-tabs right> <li><a
Ajax-returned HTML includes a table and a submit button (type=button) The table includes jQuery
I am using this jquery code to to look inside a tag and replace
HTML markup is as follows: <button id=Refresh><img src=refresh.png /></button> I am creating this button
Is there an Html parser for windows 8? I tried to look into the
I have a quite strange issue. Please, look at these screenshots: Code of that
I want to draw a graph in my Django-based site, to look like these

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.