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

  • Home
  • SEARCH
  • 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 6797095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:33:59+00:00 2026-05-26T18:33:59+00:00

So, I have this div in my HTML called ‘G36C’, I also have a

  • 0

So, I have this div in my HTML called ‘G36C’, I also have a CSS class called ‘#G36C’, so the style is applied to the div, okay?

Now, I want to change the background image in the CSS style by using JS, but I cant seem to get it to work, below is the JS I’m using:

function weaponOrganiser(){

    alert("weapon test");
    var weaponOrg = "Vector";

    //G36C
    if(weaponOrg == "G36C"){
        //$("#G36C").css('background-image', 'url("' + images/weapons/G36C/G36C.png + '")');
        $('#G36C').css('background-image', 'url("/images/weapons/G36C/G36C.png")');
        alert("G36C applied");
    }
    else if(weaponOrg == "Vector"){
        //$("#G36C").css('background-image', 'url("' + images/weapons/Vector/Vector.png + '")');
        $('#G36C').css('background-image', 'url("/images/weapons/Vector/Vector.png")');
        alert("Vector applied");
    }
}

So, all I’m doing is checking if weaponOrg = G36C, then change the CSS background to G36C.png, else if weaponOrg = Vector, then change the background to vector.

Now, When I run the code, I only get the alert(“weapon test”) to show … the rest of the alerts don’t show, which suggests to me that the if statements aren’t working …?

  • 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-26T18:34:00+00:00Added an answer on May 26, 2026 at 6:34 pm

    This is speculation because your code looks like it should work (assuming the images are where you say they are), but, are you sure weaponOrganiser() is fired after the G36C element is loaded in the DOM? Because that is the only way (in my limited tests) I could make it fail.

    If you’re using jQuery that would mean (a basic fix of) wrapping whatever calls weaponOrganiser in a $(...) call.

    If you’re not using jQuery hopefuly this will help anyway, but I don’t want to post an example for regular javascript, because while my jQuery is rusty, my real javascript has already sheared off and fallen by the wayside a few miles back. 🙂

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

Sidebar

Related Questions

I have this html: <div class=foo parent> <div class=child></div> </div> with some css: .foo{
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
I have an html like this: <div id=container1> <div class=dragme>drag me</div> </div> <div id=container2>
I have some HTML that looks like this: <div> <div class=value> <a href=# class=clicker>Some
i have this html code: <div id=ht_key class=ht_all> <div class=ht_bottom> <div class=ht_bottom_p> <span class=ht_bottom_o>
I have this html: <div id=list1>info needed for jquery script</div> <tr> <td><button class=button green>Click
I have this HTML in my page <div id='masterDIV'> <div id='divItemNumber'>23</div> <div id='divDesc'>This is
I have this HTML structure and want to convert it to an accordion. <div
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div

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.