Jquery Handson
Jquery Handson
addition
function add() {
var a = parseInt($("#num1").val());
var b = parseInt($("#num2").val());
var result = a+b;
// alert(result);
$("#total").val(result);
};
**********************************************************************
2. Login Package
function login() {
if($("#username").val() == "admin" && $("#password").val() == "password")
{alert("You are a valid user");}
else
{alert("You are not a valid user");}
**********************************************************************
3. Dom manipulation
function login() {
if($("#password").val() == "password" &&
$("#username").val() == "admin")
{
doRedirect("home.html");
}
else
{
alert("You are not a valid user");
}
};
function doRedirect(href) {
window.location = href;
};
**********************************************************************
4. Animation
function hover1(){
$("#item1-des").slideToggle();
};
function hover2(){
$("#item2-des").slideToggle();
};
function animate_big(){
$("#buy").animate({width:"200px"});
};
function animate_small(){
$("#buy").animate({width:"100px"});
};
**********************************************************************
5. AJAX
function load_des() {
$("#item1-
des").load("https://gist.githubusercontent.com/frescoplaylab/8458dd75a120cf0cfbdf45
be813d8f03/raw/84784527d760ef1f877f0b4bb02a3a5e12e32f4c/file.html");
};