AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



javascript-css: How to apply css style by javascript?

can we apply css style on html elements by javascript? If yes, Please give me source code.

javascript x 33
css x 2
Posted On : 2013-12-08 21:47:37.0
profile Garima Gupta - anyforum.in Garima Gupta
596129560202
up-rate
4
down-rate

Answers


yes, you can do it by javascript. Let´s consider a simple example in which we call a javascript function by onclick event. In which we apply the css styles on a link.

<script type="text/javascript">
function change(){
document.getElementById("link").style.color="white";
document.getElementById("link").style.background="orange";
document.getElementById("link").style.padding="20px";
}
</script>
<a href="#" id="link" onclick="change()">Click here to apply css</a>

================================= Output =================================

Click here to apply css

Posted On : 2013-12-08 22:50:19
Satisfied : 2 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188250047
Reply This Thread
up-rate
5
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in