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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:20:32+00:00 2026-06-09T18:20:32+00:00

hi i need to write if statement which checking if span has class nie

  • 0

hi i need to write if statement which checking if span has class “nie” and if so it should changed background file but my statement setting every where first bg file “bg-nie.png”, what is wrong ?

jQuery code

if ($(".rzuty span.mieszkanie").hasClass("nie")) {
        $(".rzuty span.mieszkanie").css("background", "url(img/rzuty/mieszkania/bg-nie.png) repeat");
    } else {
        $(".rzuty span.mieszkanie").css("background", "url(img/rzuty/mieszkania/bg-tak.png) repeat");
    }

HTML

<div id="rzuty07p" class="rzuty">
    <span id="c_07_226" class="mieszkanie" title=""></span>
    <span id="c_07_228" class="mieszkanie" title=""></span>
    <span id="c_07_227a" class="mieszkanie" title=""></span>
    <span id="c_07_227b" class="mieszkanie" title=""></span>
    <span id="c_07_229" class="mieszkanie nie" title=""></span>
    <span id="c_07_005" class="mieszkanie" title=""></span>
    <span id="c_07_006" class="mieszkanie" title=""></span>
    <span id="c_07_008" class="mieszkanie" title=""></span>
    <span id="c_07_007a" class="mieszkanie nie" title=""></span>
    <span id="c_07_007b" class="mieszkanie nie" title=""></span>
</div>
  • 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-09T18:20:34+00:00Added an answer on June 9, 2026 at 6:20 pm

    This can be simplified to not require an if statement. Just filter your selection further:

    var $rzutyspan = $(".rzuty span.mieszkanie");
    $rzutyspan.filter(".nie").css("background", "url(img/rzuty/mieszkania/bg-nie.png) repeat");
    $rzutyspan.not(".nie").css("background", "url(img/rzuty/mieszkania/bg-tak.png) repeat");
    

    See Demo: http://jsfiddle.net/4A4W7/


    Alternatively, this can be achieved with plain CSS:

    .rzuty span.mieszkanie
    {
       background: url(img/rzuty/mieszkania/bg-tak.png) repeat;
    }
    .rzuty span.mieszkanie.nie
    {
       background: url(img/rzuty/mieszkania/bg-nie.png) repeat;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a somewhat specific implementation of a cache, which has unique
I've a python script which works just as it should, but I need to
I need write an update statement that used multiple tables to determine which rows
I need to write a plpgsql function which executes update statement in an infinite
I need to write a case statement that will return 1 of 3 if
I need to write the following SQL statement in LINQ lambdas : SELECT *
I need to write a function that can take an if statement at runtime
The application need write file's last modification date. void Dater(String DateFile) { File file
I need to write a script in Matlab, which will read some data from
I try to write a LINQ statement which returns me all possible combinations of

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.