score:1
Accepted answer
.style
only tells you the inline style on the element, and this div has no inline style. if you want to know the style that results when combining inline style and css selectors, you need getcomputedstyle
const handleclick = () => {
console.log(window.getcomputedstyle(r.current).backgroundcolor);
}
score:0
el.style.x
is not working correctly. insteadof this use window.getcomputedstyle(el) and u can get full list of styles. as a example u can see it.
Source: stackoverflow.com
Related Query
- Getting active background color using useRef
- Sizing one component by getting the width of another one using useRef hook in React
- change active tab background color in react material-ui
- Change page background color with each route using ReactJS and React Router?
- How to change the background and text color within button using button onClick in React JS
- how to change background color when I click the button using react hooks
- How to change font color based on background color using reactJs
- How to change background color of button using react
- How to change background color of active Navigation Tab?
- Getting a reference to a React Component using useRef hook
- How to change the background color of react-bootstrap's switch (part of the Forms component) using Emotion
- Using React to change background color of a body element on click?
- Using Styled Components can't get the whole background a certain color
- How do I set the background color of a styled div using a variable?
- Trying to toggle the background color of a table row on hover using React, but nothing happens
- How to give background color to image using CSS in ReactJS?
- How Do I make my Nav Menu option change color or background when I click on it using Javascript only?
- How to make the background color of the chart as gradient using Chart.js
- How to change the default screen background color of all the pages in React JS(Next JS) using tailwind CSS
- Why I can`t set background color by using setcolor?
- Change color of active button among multiple buttons in React using material ui
- How to change button background color and text color using setSate in react?
- How to supply background color as a prop for cards using Material UI in React JS?
- how i can change background color of full page using onclick event in reactjs?
- Issue getting background color to change
- How to customize background color of button using Material UI themes
- How to change background color of active radio button in react-bootstrap?
- how to add background color only for actived item in a <li> using styled component?
- Paper background color not changing using Material UI ThemeProvider
- Getting Uncaught TypeError: Cannot set properties of null while using useRef
More Query from same tag
- React - Map function is not defined when using an external URL
- Material UI - Facing an issue that drop down options are coming below the modal window footer
- Space between filtered string from array React
- redux-offline app flickers the InitialState values on first load
- Mocking child component properties jest+enzyme+react
- DOM isn't ready in time after componentDidMount in React
- cannot set State in functional component while fetching data from Firebase in reactJS
- ReactJS Formik display error message in Red color
- React useEffect not behaving as expected
- React socket io client emitting twice to node server
- validation in react hook form?
- Rate limit the number of request made from react client to API
- Output multiple React apps from one Webpack config
- Error deploying Gatsby JS site to Netlify - “Error running command: Build script returned non-zero exit code”
- Problem while creating Tab in react ERROR (2322)
- How to pass params from one screen to another via reactnavigation v5
- React class prop onclick
- Communicating between React and Asp.net core project
- ReactNative & Expo: Trouble incrementing/decrementing to cycle through an Array
- react-navigation Screen that conceals TabBar from nested StackNavigator
- How can I manipulate the search input provided by user in react?
- How to get iOS 12 Autofill to ask to save password in React Native app?
- Create-React-App on Github-pages returns a blank page
- Redux - how to call an action and wait until it is resolved
- navigator.geolocation coords, used as params in the api url, load after the weatherAPI has already been called
- Sinon Spy is never called
- How to disable the hover effect of material-ui button inside of a styled component
- React useState rerender trigger behaves different depending of when its called
- React router not rendering components?
- Back button not loading previous component