Linked Questions

0 votes
3 answers
3k views

I have to apply multiple styles for a element, currently I have document.getElementById("element1").style.top="1px"; document.getElementById("element1").style.marginLeft="0px"; | | | document....
user3191903's user avatar
2 votes
2 answers
241 views

I want to apply more than 1 CSS styles to the button (its id is name_button). Here is my javaScript code. var name_button = document.getElementById('name_button'); name_button.style.display = '...
Nanga's user avatar
  • 73
0 votes
1 answer
437 views

I want to set the border property of an element on the right, bottom and left only without the top, so I am doing it in three lines like this: document.getElementById("...
Mahma Deva's user avatar
0 votes
0 answers
47 views

I have a question how will I make this code as one line. document.getElementById("messageBodyView").style["background-color"] = "#ffffff"; document.getElementById("messageBodyView").style["border"] = ...
QWERTY's user avatar
  • 263
0 votes
1 answer
46 views

I have tried this way to join all styles in string: pointElement.style = ` display: 'block', left: ${(rotated_x + w / 2) / scale}px, top: ${(h / 2 - rotated_y) / scale}px`; It is not ...
user avatar
400 votes
18 answers
417k views

I need to create a CSS stylesheet class dynamically in JavaScript and assign it to some HTML elements like - div, table, span, tr, etc and to some controls like asp:Textbox, Dropdownlist and datalist. ...
Himadri's user avatar
  • 8,896
17 votes
6 answers
29k views

I wanted to set my element's style as such: this.refs.element.style = { ...this.props.style, background: 'blue', }; But apparently you can't use an object to set the ref's style. I have to ...
neaumusic's user avatar
  • 10.5k
9 votes
7 answers
27k views

I want to add multiple lines of CSS with JavaScript. I know I can do this: document.getElementById(id).style.property=new style as in: <!DOCTYPE html> <html> <body> <h1 id="id1"...
IceWreck's user avatar
  • 137
5 votes
3 answers
13k views

I got an error message "Uncaught TypeError: Cannot set property 'cssText' of undefined" My Code: var div = $('.postImg2') var img = $('.postInner2'); var divAspect = 20 / 50; var imgAspect = img....
Jak Ju's user avatar
  • 57
10 votes
1 answer
5k views

I know that to replace a single style, the code looks something like this: myDOMElement.style.height = '400px'; But what if I want to completely replace the entire style object in one fell swoop, ...
AlexZ's user avatar
  • 12.2k
4 votes
3 answers
12k views

I've tried various renditions of this code to try and change a certain element for a coding exercise but non of them seems to be able to change multiple styling properties of an element on a button ...
West Coast Charlie's user avatar
5 votes
3 answers
2k views

Is it at all possible to dynamically style elements using CSS properties that are stored within a JS object? For example, changing both the width and background of a simple <div> element: <...
physicsboy's user avatar
  • 6,466
2 votes
1 answer
6k views

I'm creating a div element throught Javascript and I want to copy the styles of the canvas initialized by a game engine that I'm using. I used Object.assign to achieve this and it works perfectly on ...
Julián Bonilla's user avatar
-1 votes
3 answers
2k views

Is it possible to build sort of an Applet that you can run into any page and by selecting a element you extract it's css attributes? Imagine like firebug allows you to select the div you want to see ...
Caio Calderari's user avatar
2 votes
2 answers
447 views

So if I was to write this as a class in css I'd get something like: .cursorChange { cursor: move; /*IE*/ cursor: grabbing; /*Mozilla*/ cursor: -webkit-grabbing; /*Chrome*/ } However I ...
Dellirium's user avatar
  • 1,516

15 30 50 per page