Monday, 12 March 2012

Hide the Button using click event



















Create two file
1. hide.js
2.hide.html


In  hide.js file  add the following code

$(document).ready(function(){
$('#cl').click(function(){
var value=$('#cl').attr('value');
$('#message').toggle('fast');

if (value=='hide'){
$('#cl').attr('value','show');
}
else if (value=='show'){
$('#cl').attr('value','hide');
}
});
});

In  hide.html file  add the following code



<html>
<head>
<title>jQuery Hello World </title>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="hide.js"></script>
</head>



<body>

<input type="button"  id="cl" value = "hide" />
<p id="message">you can see this </p>
</body>


</html>


No comments:

Post a Comment