In the below code, passing your element object to the getCSS( element ) gets all the properties using getComputedStyle(element) and getPropertyValue(property) and write them in a separate division. You can scroll the results to see all the properties.
Example 1: The following example demonstrates getting all properties of <div> element with id=’srcDiv’.
Output: On clicking the ‘Get CSS’ button, the output shows.
Example 2: Below is an example to obtain the property of an <input> element with id=’inputTxt’.
Output: On clicking the ‘Get Input CSS’ button, the following output shows.
Note: Please note that the object being passed into the getCSS() function in each example.
- How to get all CSS styles associated with an element using jQuery ?
- How to reset/remove CSS styles for element ?
- How to directly update a field by using ng-click in AngularJS ?
- Function to escape regex patterns before applied in PHP
- How to send data of HTML form directly to JSON file?
- HTML | Color Styles and HSL
- How to append Angular styles in footer ?
- How to use SASS to create new set of color styles in Bootstrap 4 ?
- How to get rid of an element offset using CSS ?
- How to select all children of an element except the last child using CSS?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.