Having trouble with your jQuery/CSS background change not displaying correctly in Google Chrome?

When hovering over a link, I am using jQuery to change the background of the body. This functionality works flawlessly in Firefox and Internet Explorer, but unfortunately, Chrome (v37) does not reflect the background color change.

I attempted to troubleshoot in the JavaScript console in Chrome, however, the background remains unchanged even there.

An example illustrating the issue: The background doesn't update entirely until the window is resized. On my live website, the background does not change at all.

http://jsfiddle.net/vk503agt/


$("a").mouseover(function (){

var bg = $("body").css(["background-image","background-repeat","background-attachment","background-size","background-position"]);

var bgimage = bg["background-image"];

bg["background-image"]=bgimage.replace(/http.+jpg/,"http://fc01.deviantart.net/fs17/f/2007/129/7/4/Stock_032__by_enchanted_stock.jpg");

$("body").css({"background-image":bg["background-image"],"background-repeat":bg["background-repeat"],"background-attachment":bg["background-attachment"],"background-size":bg["background-size"],"background-position":bg["background-position"]});

});

Please note: It is vital to both read and write all utilized background properties; otherwise, certain properties will be lost when solely modifying "background-image" with jQuery.

Answer №1

The issue lies within the display:inline property of the body element. I don't see any meaningful purpose for inline in the background. Hopefully this solution resolves the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Create a custom, adaptive layout using Bootstrap that caters to different device types

I have created a website where users can upload a file with an activation code and input it manually. However, I want to restrict the file upload functionality on smartphones and tablets. Here is how I am attempting to do this: <!DOCTYPE html> &l ...

The :not selector in a chained condition is not functioning properly for a child div

I have a child div that is being impacted by the .img class. Even when I use the :not selector for this div like so .main .content .index-exp .img:not(.view-image){ /*rest*/ } it continues to affect my div. You can view the issue at this link. Is this ...

Preserving content following the use of jQuery's fadeIn/fadeOut methods

I have a jQuery function that fades in and out a sprite (sprite without text) from one background to another, and it's working as intended. However, this function is also fading out the text within an element. HTML: <div id="menu"> <ul c ...

The propagation of data in Datatables is hindered when using AJAX and JavaScript variables

Currently, I am utilizing datatables to load data through AJAX with custom data. However, when the reference variable in the custom data is changed and the AJAX is reloaded, the value of the custom data does not update. var range=1; var DataTable=$(&ap ...

What could be the reason for the specified element not receiving the CSS class as intended?

I am currently in the process of updating a website at . One of the main changes I am making is to move the "English" button to the top right corner of the page. Below is the HTML code for the button: <a href="http://hairtothequeenbook.com" class="lan ...

Fixed sidebar layout in Bootstrap 5 - Content getting pushed down by the table

In my Bootstrap 5 layout, I have a fixed-width left sidebar and a responsive table on the right. The sidebar is set to be hidden at smaller screen sizes using d-xl-block. .body { width: auto; } .side { background:gr ...

Angular 6 - detecting clicks outside of a menu

Currently, I am working on implementing a click event to close my aside menu. I have already created an example using jQuery, but I want to achieve the same result without using jQuery and without direct access to the 'menu' variable. Can someon ...

Performing a sequence of actions using Jquery Queue() function and iterating through each

I am facing an interesting challenge with an array called result[i]. My goal is to iterate through each field in the array and add it to a specific element on my webpage. $("tr:first").after(result[i]); However, I would like this process to happen with a ...

Strategies for smoothly navigating the page to a specific div every time

Currently, I am working on a form that requires submitting multiple child forms. To enhance user experience, I have incorporated jQuery functionality to display a message at the top of the page upon each submission. Now, my goal is to implement a feature w ...

Activate the counter function when the page is loaded

My current implementation utilizes the keyup function to determine word and character counts within a textarea. However, upon page load, the default values are not calculated until a key is pressed. I am looking for a solution to trigger the function on pa ...

Z-index malfunctioning - need to troubleshoot

Check out my website at Upon visiting the website on a PC, you'll notice that the navigation menu appears on the loader. Can anyone explain why this is happening? The only modifications I made to my CSS are: <style> .navbar-inverse { backg ...

Difficulty aligning headings in HTML

I'm puzzled by a strange 1px gap on the left of my h2 heading, which sits atop an h3. The font sizes are set to 40px for h2 and 12px for h3. Can anyone help me solve this mystery? Any assistance would be greatly appreciated! Thank you body { pa ...

Creating a dropdown menu by specifying specific names within an object

I am in the process of setting up a dropdown menu for all 50 states using an object that contains state names as attributes. Here's an example: window.LGMaps.maps.usa = { "paths": [ { "enable": true, "name": "Alaba ...

Is jQuery failing to correctly validate the RadioButtonList?

Using jQuery, I am attempting to validate a RadioButtonList to make sure that the user has selected one of the values. If none of the radio buttons are checked, an alert message should appear. However, even after selecting a radio button, the alert continu ...

Changing the data type of a column in an Excel file from XLSX to

I am currently working with the XLSX npm package and attempting to download a sample Excel file, add some data to it, and then upload it back. The fields in the file include MOBILE NUMBER, DATE, TIME, and NAME. When I upload the file, the values for the DA ...

Even when the Selector class is removed, Ajax continues to function seamlessly

I have two forms in two different Ajax files named ajaxChangeSimple.php and ajaxChangAdv.php. Upon clicking a button, the user should be able to toggle between these two forms. $(document).ready(function(){ $('.changeBtn').on('click',f ...

`The best method for implementing jQuery ajax with asp.net user controls`

Is it possible to implement AJAX functionality in an ASP.NET user control? $.ajax({ type: "POST", url: "*TCSection.ascx/InsertTCSection", data: "{id:'" + id + "'}", contentType: "application/json; charset=utf- ...

Utilize JQuery to extract data from an Ajax XML response

Trying to work with an XML document using JQuery. The XML content is fetched through an Ajax call: $.ajax({ url: address, type: 'GET', dataType: 'xml', success: function(data) { console.log(data); } }); When the request i ...

Prevent Android/PhoneGap Back Button with $.blockUI jQuery Plugin

I have implemented the blockUI jQuery plugin in my AJAX call: //Initiate the plugin App.utilities.Loading(); $.ajax(url, { type: "POST", contentType: 'application/json', data: JSON.stringify({ "textcontent": content }), success: f ...

The links are displaying on separate lines instead of being inline

There is a tags section on the blog detail page. The html code for it is as follows: <td class="tags"> <a href="">tag1></a>, <a href="">tag2</a> </td> However, the tags are appearing on separate lines instead of in ...