javascript style an element
// Getting the element first
var myElement = document.querySelector("#myElement");
// examples for updating styles
myElement.style.color = "blue";
myElement.style.backgroundColor = "red";// background-color
<element>.style.backgroundColor = '#000';
// background
<element>.style.background = '#000';
// color
<element>.style.color = '#fff';
// box-sizing
<element>.style.boxSizing = 'border-box';
// font-family
<element>.style.fontFamily = '\'Times New Roman\', Times, serif';
// font-size
<element>.style.fontSize = '16px';
// margin
<element>.style.margin = 0;
// padding
<element>.style.padding = '20px';
// width
<element>.style.width = '100%';
// height
<element>.style.height = '100%';
// margin-left
<element>.style.marginLeft = 0;
// font-weight
<element>.style.fontWeight = 400;
Also in JavaScript:
- file system replace line js
- convert object to json javascript
- Iterate with JavaScript Do...While Loops
- regular expression escape character
- javascript enumerate
- two object combine together javascript
- share data between livewire and alpine js
- telerik asp.net ajax error creating control
- Get rid of white space around Angular Material modal dialog
- iterate over object javascript
- VM1188:1 Uncaught TypeError: $ is not a function at <anonymous>:1:1
- showdown react
- [React Intl] Missing message for locale: "en"
- javascript non-repeating randomize array
- how to delete a line in vs code
- how to create duplicate key array in javascript
- nodejs get response time
- node sleep
- end code nodejs
- new fabric canvas set width
- angular ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
- call method in javascript
- react js http post 500 internal server error
- javascript indexof with condition