Incorporate a background image property using Jquery

Can anyone help me with adding the css background-image:url("xxxxx") property to my code?

jQuery('#'+$trackID+' .sc_thumb').attr('src',$thumb_url);
jQuery('#'+$trackID+' .sc_container').css('display','block');

I am trying to insert the $thumb_url value into a background image on the second row. I have attempted various methods, but haven't been successful. Does anyone have any suggestions on how to properly add this to the .css property?

Answer №1

give it a shot

Try using this code snippet:
jQuery('#'+$trackID+' .sc_container')
.css({
    'display':'block',
    'background-image' : 'url('+ $thumb_url +')'
    });

Alternatively, you can use:

Another option is to try:
jQuery('#'+$trackID+' .sc_container')
.css('display','block')
.css('background-image' , 'url('+ $thumb_url +')');

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

What is the best way to generate an array containing multiple arrays, each filled with dynamic Divs?

I have the following code that displays a Div when the user clicks on the Add button. For example, if the user clicks the Add button 5 times, then 5 will be displayed with the same controls/inputs under default. html <div ng-repeat="st in stu"> ...

Is it possible to dynamically load a CSS link using jQuery in a unique way? Perhaps through the use of $.ajax or another method?

As I have been using jQuery to load various resources like scripts, HTML, XML, and JSON through AJAX, a thought struck me - is it feasible to use jQuery to load or remove CSS files or links when changing the theme of a website? If this is indeed possible, ...

Create an onClick function that can direct you to a specific hyperlink without triggering a new browser window to open

Material UI is being used and a home icon has been imported into the navbar as shown below <Home edge="start" color="inherit" aria-label="home" onClick={event => window.location.href='/ <Home fontSize="lar ...

Discovering the content within table cells by utilizing JavaScript functions linked to specific IDs

I am currently working on a project that involves a dropdown list: <select id="itemsList" onchange="gettingList()"> <option>Please choose an option</option> <option value="50">Shampoo</option ...

Mapping an HTTP object to a model

Currently facing an issue with mapping an http object to a specific model of mine, here is the scenario I am dealing with: MyObjController.ts class MyObjController { constructor ( private myObj:myObjService, private $sco ...

When attempting to send data to the ServiceStack RESTful service, an error message of 'Access is denied' was received

I created a RESTful service using ServiceStack to send data to a database. It worked perfectly when tested locally. However, after deploying it to a server and running the same jQuery $.ajax call code, I encountered an 'Access is denied' error. I ...

The $(window).load(function() function is unable to run once the entire document has finished loading

I have not been able to find the solution in the following circumstances: In an HTML document, I successfully load multiple other HTML files. However, within one of these included HTML files, specifically "navmenu.html," I want to execute a script with a ...

Executing PHP to capture and showcase the HTTP request received from one page onto another

As a beginner in web development, I humbly ask for patience as I navigate through unfamiliar territory. If possible, please guide me through the logical steps necessary to accomplish the task at hand. I am currently working with PHP and need assistance i ...

Can a linked checkbox be created?

Is it possible to create a switch type button that automatically redirects to a webpage when turned on by clicking a checkbox? I'm working on implementing this feature and would like to know if it's feasible. ...

Unlock the potential of utilizing JQuery with Laravel through the NPM integration

Being a newbie in the world of web development, I have recently started working with the Laravel framework and using npm to handle packages. However, I am facing an issue when trying to implement JQuery. Bootstrap is already integrated into my Laravel proj ...

Fresh sheet with a view through the window

I need to print a table and two popup windows when an action is triggered, but I am facing issues with the page-break in CSS. None of the solutions I have attempted so far seem to work. Currently, the two pop-up windows overlap with the table data, and I w ...

Enhance Your Website with HTML and JavaScript

Here is the code snippet I am working with: sTAT **javascript** var acc = document.getElementsByClassName("item-wrapper"); var i; for (i = 0; i < acc.length; i++) { acc[i].onclick = function(){ this.classList.toggle("selected"); this.nextElementS ...

Is there a way to verify and send notifications when duplicate entries are added to my table?

Whenever a make and model are added using the "add" button, I need to ensure that there are no duplicates. If a duplicate is found, an alert should be displayed, and the entry should not be added to the table. Unfortunately, I have been unable to find a so ...

Passing values of variables to child functions in JQuery

When I run this code, the variable "el" returns as undefined. $('.element').each(function(){ var el = $(this); setTimeout(function(el) { el.css({ marginTop: -100 }); }, 550); $(window).resize(function(el) { setTim ...

What is the best way to assign an object variable within an array state?

My current state looks like this: const [tags, setTags] = useState([{id: 1, label: "random"}, {id: 2, label: "important"}]) const [input, setInput] = useState("") const [selectedTag, setSelectedTag] = useState([]) In addition ...

A guide on integrating mat-select into Angular input fields

I've been trying to implement a mat-select dropdown on my input field, but for some reason, when I click on the arrow, nothing happens and the list doesn't show up. Usually, with autocomplete, when a user starts typing, all the options are displ ...

Text aligned at the center of the Y and X axis

I am looking to center my content along the Y axis instead of only on the X axis. To prevent the page from expanding beyond its current size, I have applied the following CSS: html { overflow-y: hidden; overflow-x: hidden } What I want to achieve is havi ...

"Exploring the symbiotic relationship between Node.js and Express.js: an

I recently started learning Node.js and Express.js. I used the Express.js executable (express) to create an express application, which generated the following lines in app.js: ... var app = express(); http.createServer(app).listen(app.get('port' ...

The showdown: JQUERY $(document).click versus $(document).ready

$(document).ready(function(e) { if ($('#sidebar').hasClass('active')) { $('#dismiss, .overlay').on('click', function() { $('#sidebar').removeClass('active'); $('.overlay&apo ...

Showing information from asynchronous AsyncStorage.getItems in React Native

In my app, users have to validate their success on challenges by clicking a validation button which saves the "key":"value" pair of the challenge using this function: async function validate(challenge_nb) { try { await AsyncStorage.setItem(challenge_n ...