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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:22:49+00:00 2026-06-01T19:22:49+00:00

jQuery selector Selecting specific span tags I had this problem with jQuery’s selector. It

  • 0

jQuery selector

Selecting specific span tags

I had this problem with jQuery’s selector. It was a problem for hours. It could not select that specific span tag that I wanted to manipulate and that’s why I’m stuck scratching my head with this one.

My goal was to add different classes for each span tag that had different style values.
Thus I almost succeeded I couldn’t figure out how to add different classes to each span tag, so I ended up clueless.

I basically want the span with font-size of 180% to be in a specific class doesn’t matter which really cause I can change that later if the code works. The other span tag with font-size of 100% should also have a class, the other class. I hope you get more clarity in what I’m trying to do now at least that’s what I’m hoping for.

The code exists in the link below, feel free to post a fix and optionally but not required a explaination of why it didn’t work! thank you.

jQuery Submission: JS Bin Post

Here’s the code itself aswell.

    var val1 = "font-size: 180%";
    var val2 = "font-size: 100%";
    var title = $("span").attr("style");
    
    $(function(){
    if ($("span:contains('font-size: 100%')")) {
      $('span').addClass("text_shadow2");
      if ($('span').has("text_shadow1")) {
         $('span').removeClass("text_shadow1");
      }
    }
        if ($("span:contains('font-size: 180%')")) {
           $('span').addClass("text_shadow1");
           if ($('span').has("text_shadow2")) {
               $('span').removeClass("text_shadow2");
           }
        }
        },function(){
        if ($("span:contains('font-size: 100%')")) {
        $('span').addClass("text_shadow2");
        if ($('span').has("text_shadow1")) {
              $('span').removeClass("text_shadow1");
           }
        }
        if ($("span:contains('font-size: 180%')")) {
        $('span').addClass("text_shadow1");
            if ($('span').has("text_shadow2")) {
               $('span').removeClass("text_shadow2");
               }
        }
    });

    if ($(val1==title)) {alert("1. "+title);} 
    if ($(val2==title)) {alert("2. "+title);}
  • 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-01T19:22:51+00:00Added an answer on June 1, 2026 at 7:22 pm

    You could do something like this to parse the style attribute. Browsers aren’t going to set the font-size property to a percentage but will do the calcs instead

    $('span').filter(function(){
        return $(this).attr('style').match('180%');
    }).addClass('someClass');
    

    Demo: http://jsfiddle.net/AbZBD/

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

Sidebar

Related Questions

I have a problem with selecting not first selector using attributeContains jQuery('div[id*=abc]:not(:first)').hide();
I've built a jQuery selector for a function which looks like this: $('html').not('.table-main tr[selected]').mousedown(
Is there a clever jQuery selector for selecting a text node like this: <div><input
I have a jQuery selector that queries elements by tag name and class. In
I have a jQuery selector that is running way too slow on my unfortunately
Internet Explorer does not like my Jquery selector. Not sure if it's my weak
Does anyone have any idea what this jQuery selector will do? object.find('td:eq(1) div div');
I understand that selecting by the class attribute in jquery is one of the
I certainly know how to select confine a jQuery selector to children of a
Let's say that I have a multiple select field like this: <select id=foodlist multiple=multiple>

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.