• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How can I change the value of CSS custom property by 1 on button click using jQuery?

Resolved: How can I change the value of CSS custom property by 1 on button click using jQuery?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

How can I change the value of css custom property by 1 on button click using jQuery?
I want to change the value by 1 when the next button is clicked, I tried to use this x variable and then add one to it whenever the next button is clicked but it didn’t work. What should i do to get the code working, if I want the x variable to increase by 1 when i click on the next button.


Answer:

Use CSSStyleDeclaration.getPropertyValue() to get the current --slider-index value, assign to a variable, such as x, and pre-increment it’s value, as in: ++x.
For example:


If you don’t need to use the --slider-index value in that code block again, you can skip assigning to a variable and just add one to the current --slider-index value:

If you have better answer, please add a comment about this, thank you!

css html javascript jquery
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.