Hey ninjas, in this JavaScript tutorial, we’ll be looking again at the setAttribute method to control in-line styling of our HTML elements, as well as utilizing the ‘style’ property that all DOM objects have access to.
If you have any questions at all, fire away :).
SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1
========== JavaScript for Beginners Playlist ==========
========== CSS for Beginners Playlist ==========
========== HTML for Beginners Playlist ==========
========== The Net Ninja ============
For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk
========== Social Links ==========
Twitter – @TheNetNinja – https://twitter.com/thenetninjauk
Original source
17 responses to “JavaScript Tutorial For Beginners #36 – Changing CSS Styles”
Couldn't thank you enough Sir!
You have made me feel so much more confident man about JavaScript, I'm pretty good at Html/Css(steady improving), have always been really afraid I couldn't understand the logic of JavaScript, thank you so much man!
great 👌
2:20 can we do like this : link.setAttribute ("style" , link.style + " left : 10px ; " ) ;
so we don't have to write the old style ?
thank you this is a very helpful video
4:06 pro-tip: you can use up/down arrows in console to reuse recently commands. Hope this help somebody 🙂
how to give hover style in js
also how to fix parentelement undefined problem
You are awesome.
At last, I understand JS.
Quickly and simply, this is that what i needed
Net Ninja just makes these videos as an excuse to teach us and do some development of his website at the same time XD
For adding classes instead of replacing them, we can use
title.className += " " + "your_class_name_here"
The space preceding is important because js concatinates it with the previous class
Thanks for the clear short tutorials. What would be a practical use for this? Apart from changing elements in the console window?
Best net ninja teacher ever. JS so simple thanks to u. THANK YOU
I had been beating my head up against a rock trying to comprehend the basics of JS and your channel helps tremendously. Thank you! And lovely accent.
super tutorials– THANK YOU
When viewing the "text" list for style, the property is referenced as "background-color," but when setting the attribute it's camel cased without a hyphen (which is logical as attribute names cannot have hyphens as these would be minus signs). Is inconsistency here to keep the riff-raff out?
For the first example, would it be the same to put "title.style.position = 'relative';" ?
Thanks for this! Quick question though – if your CSS is stored in a linked .css file, will this update it there or just enter the new styles in the HTML?