---
title: "Problem in assign css on button control by javascript"  
description: "Problem in assign css on button control by javascript"  
author: "Anonymous User"  
published: 2011-01-11  
updated: 2011-01-14  
canonical: https://www.mindstick.com/forum/148/problem-in-assign-css-on-button-control-by-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Problem in assign css on button control by javascript

we use one asp [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) and apply css [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) for [background color](https://www.mindstick.com/forum/12937/how-to-style-togglebutton-so-that-the-background-color-is-white) and forecolor on [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event)\
[problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) in syntax how use it \
please give the solution ![Problem in assign css on button control by javascript](https://www.mindstick.com/app_images/htmleditor.icons/eusa_wall.gif) \
thanx in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Amit Singh

Check this code\
\

```
<asp:button ID="Button1" runat="server" text="Button"  />
       <script type="text/javascript">        
               document.getElementById("Button1").style.backgroundColor = "red";
               document.getElementById("Button1").style.color = "Green";        
        </script>
```

![Problem in assign css on button control by javascript](https://www.mindstick.com/app_images/htmleditor.icons/eusa_dance.gif)\


---

Original Source: https://www.mindstick.com/forum/148/problem-in-assign-css-on-button-control-by-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
