Pages

Thursday 30 May 2013

How To Add / Remove CSS Class Dynamically to DIV Elements Using jQuery in c# Asp.net

How To Add / Remove CSS Class Dynamically to DIV Elements Using jQuery in c# Asp.net


Program:

.Aspx File:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Add Remove CSS Classes Dynamically</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('#btnaddCSS').click(function () {
            $('#divsample').addClass('divclass')
        });
        $('#btnRemoveCSS').click(function () {
            $('#divsample').removeClass('divclass')
        });
    })
</script>
<style type="text/css">
.divclass
{
background-color:#B52025;
color:White;
width:30%;
}
</style>
</head>
<body>
<div id="divsample">
<h4>jQuery Add or Remove CSS Classes</h4>
<p>Welcome to fantasyaspnet.blogspot.in <br /><br/>It will provide different kind .Net related articles</p>
</div>
<div>
<input type="button" id="btnaddCSS" value="Add CSS Class" />
<input type="button" id="btnRemoveCSS" value="Remove CSS Class" />
</div>
</body>
</html>

Live Demo:

jQuery Add Remove CSS Classes Dynamically

jQuery Add or Remove CSS Classes

Welcome to fantasyaspnet.blogspot.in

It will provide different kind .Net related articles

No comments:

Post a Comment