JavaScript How to assign background image of button to a variable using jquery css assign background image to div,assign background image in html,

I want to assign background image of button in a jquery variable with css.I have written code but it not work.

var cmp1;
var cmp2;

var bg = $("#mq3").css('background-image');
var bg1 = $("#mq6").css('background-image');
var bg2 = $("#mq9").css('background-image');

$(document).ready(function() {    
       $("#mq9").click(function() {
           //alert("Hello Welcome");
           if ($("#mq9").css("background-image") === bg2) {
               $("#mq9").css("background-image", "url('images/bkv.png')");

               cmp1 = $("#mq9").css('background-image');
               cmp2 = $("#mq3").css('background-image');
               cmp3 = $("#mq6").css('background-image');

               if (cmp1 === cmp3) {
                   alert("welcome mohit");
                   //setTimeout("window.open('Qtwo.html')",3000);
              }
          } else {
               $("#mq9").css("background-image", "url('images/cmst.png')");
               bg2 = $("#mq9").css('background-image');
          }
     });
});
Answer:1

Main module being injected with everything; require('./dashboard'); module.exports = angular.module('college', ['college.dashboard']) .config(function ($stateProvider) { $stateProvider ...

Main module being injected with everything; require('./dashboard'); module.exports = angular.module('college', ['college.dashboard']) .config(function ($stateProvider) { $stateProvider ...

I have the same config blocks for all the angular apps on my site, all in different files. app_1.config([ "$httpProvider", function($httpProvider) { $httpProvider.defaults.headers.common['X-...

I have the same config blocks for all the angular apps on my site, all in different files. app_1.config([ "$httpProvider", function($httpProvider) { $httpProvider.defaults.headers.common['X-...

  1. share same config file

I want to generate a new unique 20 digits string from a string that represent a number For example : var uid = key.pseudoHash("00000000000000000000"), // "45021-78054-45021-16875" uid = key....

I want to generate a new unique 20 digits string from a string that represent a number For example : var uid = key.pseudoHash("00000000000000000000"), // "45021-78054-45021-16875" uid = key....

I'm developing an extension for Google Chrome and the problem I'm having is I need to be able to call a JavaScript function that belongs to the webpage that's opened in the tab. For details, the ...

I'm developing an extension for Google Chrome and the problem I'm having is I need to be able to call a JavaScript function that belongs to the webpage that's opened in the tab. For details, the ...

  1. chrome.tabs.create
  2. chrome.tabs.create example
  3. chrome.tabs.create callback
  4. chrome.tabs.create not working
  5. chrome tabs create content script
  6. chrome.tabs.create undefined
  7. chrome.tabs.create callback not working
  8. chrome.tabs.create incognito
  9. chrome.tabs.create new window
  10. chrome.tabs.create background
  11. chrome.tabs.create executescript
  12. chrome.tabs.create send message
  13. chrome.tabs.create popup
  14. chrome.tabs.create post
  15. chrome.tabs.create parameters
  16. chrome tabs create callback example
  17. chrome.tabs.create( url
  18. chrome.tabs.create( url new url )
  19. chrome.tabs.create firefox
  20. chrome tabs create function