Skip to main content

Javascript Mouse Events

Now i'm going to explain you about click events. An event can be generated by clicking of mouse or pointing of mouse. Its very simple just use objects and make their this function. Main benafit of javascript is that it can be embedded in HTML very easily either in head section or body section or you may create a seprate file of javascript and save that file with the extension of .js
The simple method of adding javascript file in html is to call that file in head section.



HTML & Javascript Code :

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<title>click event</title></head>
<body>
<div id="box" onmousedown="mDown(this)" onmouseup="mUp(this)"> Click me</div></br>
</br>
<div id="box" onmouseover="mOver(this)" onmouseout="mOut(this)"> click me too</div>
<script type="text/javascript">

function mDown(obj)
{
obj.style.backgroundColor="blue";
obj.innerHTML="release me"
}
function mUp(obj)
{
obj.style.backgroundColor="#F17A9E";
obj.innerHTML="Click me"
}
function mOver(obj)
{
obj.style.backgroundColor="green";
obj.innerHTML="mouse is on me"
}
function mOut(obj)
{
obj.style.backgroundColor="#F17A9E";
obj.innerHTML="mouse is not on me"
}

</script>
</body>
</html>

CSS: 

#box{
    background-color:#F17A9E;
    padding:20px 10px 40px 20px;
    height:30px;
    width:60px;
    margin-left:30px;
}

Enjoy this code and apply it as per your requirment. Hope you will like this.

Comments

Popular posts from this blog

Network Topologies (Tutorial-4)

Topology refers to the way in which the network of computers is connected. The choice of topology is dependent upon--- Type and number of equipment being used  Planned applications and rate of data transfers  Required response times  Cost Types of Network Topologies Physical Topology: Physical topology defines how devices are connected to the network through the actual cables that transmit data(physical structure of the network)  Logical Topology: Logical Topology (also referred to as Signal Topology) is a network computing term used to describe the arrangement of devices on a network and how they communicate with one another.

Cisco Hierarchical Model

Cisco Hierarchical Model Defined by Cisco to simplify the design, implementation, and maintenance of responsive, scalable, reliable, and cost-effective networks. The 3 layers are logical and not physical – there may be many devices in a single layer, or a single device may perform the functions of 2 layers, eg: core and distribution. The Cisco Hierarchical Model

Eden: PHP Library To Get Things Easy For PHP Developer

Eden is PHP Library designed for helping developers in their rapid development work. In Our most of the project we have to integrate our developed website or application with most of  the social networking websites like Google, Facebook, Twitter, yahoo etc. so what we do is we integrate libraries of different websites differently Although We could make the code reusable but still if the websites increases then confusion will also increases. Adding different libraries form different sources add more complexity to your project and ends up to be hard to maintain. Eden simply a set of reusable components, that works with any PHP framework and CMS. Eden makes code logical and readable with dead simple syntax. Eden Will work With Most Of Web services including Amazon Web service Facebook Foursquare Google twitter tumbler Paypal Yahoo You could Download the File From  Eden Official Website  and Can use this will just a simply including this...