DHTML Unit 3 programs

Unit 3 Programs


1.Test if jQuery is loaded.
ANS)

<!DOCTYPE html>
<html>
<head>
<title>Unit 3 - prg 1</title>
<script src = "jquery.js" > </script>
</head>
<body>
<script>
$(document).ready( function()
{
$("p").click(function()
{
alert("This alert box show using Jquery......!");
});
});
</script>
<p>Click for alert box</p>
</body>
</html>


2.Scroll to the top of the page with jQuery.
ANS)

<html>
<head>
<title>Unit 3 - prg 2</title>
<script src="jquery.js"></script>

<script >
$(document).ready(function()
{
$("#top").bind("click",function()
{
$("html,body").animate({scrollTop:0},"slow");

});
$("#bottom").bind("click",function()
{
$("html,body").animate({scrollTop:1000},"slow");

});
});
</script>

</script>
</head>
<body>
<a  id="bottom"><input type="button" value="Bottom" id="bottom"></a>

Extra text ................<br>
You can write your own text<br><br>
Extra text ................<br>
Extra text ................<br>
Extra text ................<br>
write atleast more than 30 lines..........!!!<br>
Extra text ................<br>
Extra text ................<br>

<a id="top"><input type="button" value="Top" id="top"></a>

</body>
</html>


3.Disable right click menu in html page using jquery.
ANS)

<!DOCTYPE html>
<html>
<head>
<title>Unit 3 - prg 3</title>
<script src = "jquery.js" > </script>
</head>

<body>
<script>
$(document).ready( function()
{
$("p").bind("contextmenu",function()
{return false;
});
});
</script>

<p>Copy this sentence if u can without using keyboard</p>

</body>
</html>

4. Write a Jquery for Limit character input in the textarea including count.
ANS)

<!DOCTYPE html>
<html>
<head>
<title>Unit 3 - prg 4</title>
<script src = "jquery.js" > </script>
</head>
<body>

<lable>Max 15 char</lable>
<p>Enter your name : </p>
<textarea  maxlength=15 ></textarea>
<span id="txt">15</span> Remaming characters.

<script>
var max=15;
$(document).ready(function ()
{
$("textarea").keyup(function(){

var textlen = max - $("textarea").val().length;

$("#txt").text(textlen);  //to print remaining length
});
});
</script>

</body>
</html>

5. Write a jquery to Display a message when the contextmenu event is triggered on the paragraph elements.
ANS)

<!DOCTYPE html>
<html>
<head>
<title>Unit 3 - prg 5</title>
<script src = "jquery.js" > </script>
</head>
<body>

<script>
$(document).ready( function()
{
$("p").contextmenu(function()
{
alert("Right click is triggred");
});
});
</script>

<p>this is tag p right click on this text to see alert box........!</p>

</body>
</html>

Comments

Popular posts from this blog

C++ Practice Program

Cloud Computing Important Question-Answer for University Exam

Software Testing Gujarat University Important Questions For Exam