jQuery Hands-on Solution | TCS Fresco Play | Fresco Play | TCS
Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).
All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!
Code for Hands-On
Try it Out - Animations, Try it Out - DOM Manipulation, Try it Out - AJAX calls
*****even though topic is animation, DOM Manipulation and AJAX calls, login code completed the hands on :)
do login:
function login() {
if ($("#username").val() == "admin" && $("#password").val() == "password") {
alert("You are a valid user");
} else {
alert("You are not a valid user");
}
}
do manipulation:
function login() {
var uName = $('#username').val();
var pwd = $('#password').val();
if(uName == 'admin' && pwd == 'password') {
doRedirect("home.html");
}
else {
alert('You are not a valid user');
}
};
function doRedirect(href) {
window.location = href;
};
Try it Out - Event Handling
function login() {
var uName = $('#username').val();
var pwd = $('#password').val();
if(uName == 'admin' && pwd == 'password') {
alert('You are a valid user');
} else {
alert('You are not a valid user');
}
};
jQuery Hands-on: Addition of two numbers
function add() {
var num1 = $('#num1').val();
var num2 = $('#num2').val();
var total = parseInt(num1) + parseInt(num2);
$('#total').val(total);
};
Animation :
function hover1(){
$("#item1-des").slideToggle();
};
function hover2(){
$("#item1-des").slideToggle();
};
function animate_big(){
$("#buy").animate(
{"width": "200px"});
};
function animate_small(){
$("#buy").animate(
{"width": "200px"});
};
AJAX
function load_des() {
$("#item1-des").load( "https://gist.githubusercontent.com/frescoplaylab/8458dd75a120cf0cfbdf45be813d8f03/raw/84784527d760ef1f877f0b4bb02a3a5e12e32f4c/file.html")
};
Post a Comment