Tips for adjusting the padding percentage of a div with jquery

In my video player application, I have implemented a responsive window for playing videos.

.player-window {
    position: relative;
    padding-bottom: 42%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
} 

My goal is to dynamically change the padding-bottom % value whenever a user clicks on a video thumbnail. Here is an attempt at achieving this functionality:

$('.thumbnail').on('click', function() {
    $('.player-window').css(padding - bottom: '50%');
    $('.player-window').html('embedded video');
});

Answer №2

It is not possible to include the - symbol in an object property literal without enclosing it in quotes. You can opt for camelCase formatting or place quotes around the property.

$('.player-window').css({paddingBottom: '50%'});

alternatively,

$('.player-window').css({'padding-bottom': '50%'});

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

If I have a lengthy passage filled with hyperlinks and need to retrieve all the links, would it be more efficient to use front-end or back-end methods

Looking for advice on how to extract a list of all the links within a large block of HTML code. Unsure whether to use the backend with rails or the frontend with jQuery for processing on the client end during each page load. Any thoughts on the pros and ...

Create a collection of SVG illustrations using Vivus.js

Is it possible to draw multiple SVGs using Vivus.js without having to call the function for each individual drawing? I've encountered an issue with the second drawing not animating properly. Any suggestions or experience with this? Check out this pen ...

Incorporate a Variety of Elements onto Your Webpage

I have developed a custom tooltip plugin using JQuery, and I am implementing it on multiple A tags. Each A tag should have a unique tooltip associated with it, so I have the following code: var $tooltip = $("<div>").attr("id", tooltip.id).attr("cla ...

Control the switch for CSS selectors

Consider the following scenario where CSS rules are defined: <style> table {background:red;} div {background:green;} </style> In addition, there is HTML code that calls a JavaScript function: <table onclick="tu ...

Is there a way to insert a row into a datatable without needing to perform an Ajax reload or using the

When using row.add(…) on a datatable, I encounter an issue where it refreshes via an ajax call when draw() is activated. This leads to the new row not being visible because the data is reloaded from the database. The UX flow behind this scenario is as f ...

CSS: incorrect text alignment

I'm encountering an error with text-align. I want my text aligned to the left, but it's starting from the center. I've tried to fix it without success. Can someone please review and correct my code? CSS .text { width: 100%; height: ...

I'm having trouble getting the modal to load automatically when the page loads. The usual bootstrap method doesn't seem to be working, and I'm

Trying to make a modal load on page load seems like a simple task, but for some reason, it just won't work! It functions perfectly fine when triggered by a click. The bootstrap and jquery scripts are included as shown below: <script src="https:/ ...

Tips for controlling the visibility of elements based on the parent class containing an <a class="active">link</a> element

<div class="set"> <a href="javascript:void(0);" class="active">SAMPLE <img class="" src="/active-arrow.svg"> </a> <div class="content">details </div> ...

Handling AJAX requests using jQuery

I'm currently in the process of learning how to utilize jQuery Ajax. Could you explain to me the significance of function(response), as well as what exactly is meant by response == 1 and response == 2? jQuery.post(ajaxurl, data, function(response) { ...

Using jQuery to Create and Export XLS File

Need assistance with exporting data to an xls file sorted by date. Unsure how to resolve this issue. Here is the jQuery Code : $('#report_xls').live("click", function(){ var url = "ticket.report.php"; var startdate = $('input:text[ ...

Do mobile CSS/HTML have distinct rules to follow?

I am having trouble displaying a background image in CSS. Additionally, I am unable to set a background color for a div. #mlogo { background-image: url(/mobileimages/2015LOGOFB.jpg); background-size: 100%; background-position: top; backgro ...

Styling the inner background color of a text input field using CSS

My text field looks great everywhere, except in Opera where it blends into the background color. Is there a way to keep the inside of the text field white only? Setting the background(-color) to white changes the entire square element background, which is ...

Setting the timer: setTimeout function

As a beginner in jQuery, I am looking for the most efficient way to create a slideshow that automatically changes pictures and button statuses at set intervals. However, I want the auto image transitions to pause when a user clicks on any of the image butt ...

What steps can I take to modify the class of a button once it has been clicked using JQuery?

Currently, I am experimenting with Jquery to dynamically change the classes of bootstrap buttons when they are clicked. However, I have encountered a limitation while using toggleClass. The issue is that I am only able to toggle between two classes, whic ...

What is the best way to set up a horizontal navigation system on a webpage?

Below is the code for a horizontal page dragging navigation system inspired by www.blacknegative.com. In this system, users can click and drag left or right to navigate through different pages. The current setup allows for four pages, but I need to expand ...

What is the proper way to specify the background image path in CSS?

My CSS file is located at: Project/Web/Support/Styles/file.css The image I want to use is found here: Project/Web/images/image.png I am attempting to include this image in my CSS file. I have tried the following methods: 1) background-image: url(/images ...

Transform content div into a clickable element by incorporating nested divs

Here is my current layout: <div id="content"> <div id="img"><img src=""></div> <div id="main">Some content</div> <div id="btn" class="hidden"><button>Submit</div> <div class="hidden">Some ...

Troubleshooting: Page Unable to Import/Execute Linked JavaScript on WebStorm with Node.js Backend

I've been following W3School's jQuery tutorial, but I'm encountering some issues with importing scripts to an HTML document hosted on a Node server in WebStorm. I have properly installed and enabled the jQuery libraries under Preferences &g ...

Instructions for incorporating a glyphicon glyphicon-calendar into a bootstrap dropdown using pug

I am a beginner in the world of pug and I'm trying to include the glyphicon glyphicon-calendar in a dropdown menu labeled "All months". .pull-right select.form-control.btn-primary#selectMonth(style="margin-top: -15px;") option(selected="selecte ...

Align a single <td> element in the center of a row while the other row contains multiple <td> elements

I am facing an issue with centering a <td> element in a row, especially when there are multiple <td> elements in the same row. The first row's <td> element remains fixed in the first column position and does not move to the center as ...