Is there a way to update the value of a property using jQuery?

Is there a way to retrieve the "top" property value along with its inline CSS adjustment?

<article class="stack" style="position: absolute; left: 741px; top: 1000px;">
</article>

I'm looking to subtract 200px from the top value, in this case changing it from 1000px to 800px.

Any assistance on achieving this task would be greatly appreciated. Apologies if my question is unclear.

Answer №1

Here is a simple way to achieve this:

let position = $('article.stack').css('top'); // retrieve the Top value
console.log(position);

$('article.stack').css('top',parseInt(position)-200); // update the Top value

position = $('article.stack').css('top');
console.log(position);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<article class="stack" style="position: absolute; left: 741px; top: 1000px;">
</article>

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

Is there a way to create a function that can show the pathway on the Browser Console?

I am looking to create a function that will show the path in the Browser Console when a link in the menu of a sub-category is clicked. The menu setup resembles this () on an e-commerce website. For instance: Perfume => ForMen => Cologne How can I r ...

Display the child elements in an HTML document that have the same class name as the parent element, while concealing all

<div class="element-2"> <div class="element-1"> <p>div 1</p> </div> <div class="element-2"> <p>div 2</p> </div> </div> The main objective is to display only child divs with sim ...

Attempting to limit entry to a pathway when the loggedIn criterion is satisfied

I am currently facing a challenge with restricting access to the login page if the user is already logged in. I have been attempting to achieve this by checking for an existing token in the localStorage. Do you have any suggestions on how I can troublesh ...

Extracting text sizes from HTML and CSS

Struggling to extract the font size of text sections from an HTML page. Despite exploring python libraries like cssutils and beautiful-soup, my efforts have been fruitless so far. My homemade html parser only captures font sizes within the html itself, n ...

How to access Object ID and other properties with Angular JS in combination with Jquery UI Sortable

Below is the code snippet I am currently working with. It involves rendering a sequence of images and applying the Sortable property: <span data-ng-repeat="img in vehilceimages" style="position: relative"> ...

Disable video playback on Internet Explorer 7 (with Rob W's method)

I've successfully implemented this script created by Rob W from StackOverflow, but unfortunately it's not working on IE7. You can view the script on this jsfiddle page. I've also tried importing this to enable JSON on IE, but the issue pers ...

Comparing the construction of web pages with HTML/PHP to the

I am facing an issue with my ajax call where the responseText is returned using a while loop, but the embedded JavaScript is not being loaded. To work around this problem, I have decided to build most of the html on the client side using JavaScript. Coul ...

In JavaFX, when adjusting the transparency of a popup window, only the brightness changes while the solid color remains unchanged, effectively concealing

Is it possible to have a transparent popup window (errorDialog.fxml) on top of the main window (mainWindow.fxml) with 50% opacity while still showing the content of the main window underneath? My attempts at setting the background color of the overlay insi ...

A list of options displaying unfinished values from the ajax response

Here is the code I am using to display values in a list box: $.ajax({ type: "POST", data: queryvalue, url: "inputaction.php", success: function (data) { switch (action) { case "GetMake": console.log(dat ...

What is the process for generating an attribute in a system?

If I want to create an element using plain JavaScript, here is how I can do it: var btn = document.createElement('button'); btn.setAttribute('onClick', 'console.log(\'click\')'); document.body.appendChild( ...

Properly specify the type annotation for a view function that does not accept any arguments

As I continue my Elm learning journey, I have come across a beginner's question. I'm struggling to properly type annotate a function that simply returns a pure div element. header = div [] [ text "Hello" ] Can someone provide guidance on th ...

Displaying live updating information (Progress) on my website

I'm in the process of creating a web page that displays data from a datatable in a grid view. There's also a button labeled "Send To Excel." When a user clicks this button, the program begins generating a report by writing the datatable content i ...

The date error from day.js in Firefox is not valid

My date is formatted as 2022-01-27 09:23:48 UTC and I am trying to parse it into MMMM-DD-YYYY format (Jan-27-2022) using day.js. The parsing works well in Chrome, but Firefox returns an 'Invalid' result. import dayjs from "dayjs" const ...

Oops! It seems like there was an issue trying to access properties that are undefined while reading 'pipe' in Angular12

I encountered an issue when trying to send an AJAX request, displaying the following error message: ERROR TypeError: Cannot read properties of undefined (reading 'pipe') This error occurred in the ajax-loader.interceptor.ts class export class A ...

Tips for delaying the loading of a video until after the initial page load in React/NextJS

I am looking to improve my lighthouse scores by delaying the loading of a video until after the page has completely loaded. Since the video is below the fold and only visible upon scrolling, I want it to wait for everything else on the page to load first i ...

To achieve this, my goal is to have the reels start playing on a separate page when a user clicks on the designated image. I am currently working on a project that involves this

When a user clicks on the designated image, I want the reels to start playing on a separate page. In my main project, I have a reels project within it, with the reels project built in ReactJS and the main project in React TypeScript. For example, if a user ...

Utilizing a datatable plugin to enhance an HTML table within a WordPress website that is connected to a database

My current WordPress site features a main HTML table with a basic header of 7 columns. The rows in this table are filled from a database variable, and it works flawlessly. Recently, I was tasked with making this entire table sortable, filterable, and searc ...

Implement a deletion option for each entry within a bootstrap grid on PUG

I am having trouble adding a button to each record in a bootstrap table using the pug templating engine. It seems that the input tag is not working as expected. Can someone please assist me with this issue? .jumbotron h1 User Report .container table ...

Should I use "npm install" or "sudo npm install -g"

When it comes to installing certain packages, sometimes running sudo npm install -g is necessary, while for others simply using npm install is enough. What causes this difference and why does it exist? Take the following examples: npm install -g grunt-c ...

"Exploring the world of arrays and looping in

Can someone assist me with this issue? I am currently stuck in JS Arrays & Loops and I can't understand why it's not returning "0" when the function is empty. function sumArray (numbers) { // your code var numbers = [1, 2, 3, 4]; if (nu ...