linux1880 Posted May 18, 2010 Share Posted May 18, 2010 hi folks how to add css styles to html elements using javascript ? pls help Thanks Link to comment https://forums.phpfreaks.com/topic/202137-how-to-add-css-styles-to-html-elements-using-javascript/ Share on other sites More sharing options...
Omirion Posted May 18, 2010 Share Posted May 18, 2010 element.style.[property] = value //prototype Example: var elem = document.getElementById("myDiv"); elem.style.left = 100px ; Link to comment https://forums.phpfreaks.com/topic/202137-how-to-add-css-styles-to-html-elements-using-javascript/#findComment-1060196 Share on other sites More sharing options...
Ang3l0fDeath Posted May 23, 2010 Share Posted May 23, 2010 elementObject.style //This is how you tell an elementObject its going to be styled in CSS elementObject.style.color='white';// OR ='#ffffff'; elementObject.style.backgroundColor='red';// OR ='#800000'; elementObject.style.padding=5; elementObject.style.textAlign='center'; hopefully thats enough examples for you to understand it. Link to comment https://forums.phpfreaks.com/topic/202137-how-to-add-css-styles-to-html-elements-using-javascript/#findComment-1062189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.