Quotes help make search much faster. Example: "Practice Makes Perfect"

Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Friday, June 7, 2013

Codeschool Sample Solution Keyup Event Handler II


$(document).ready(function() {
  $("#nights").on("keyup", function() {
    //var days = $(this).val();
    //var pricePerDay = $(".tour").data('daily-price');
    //var totalPrice = days * pricePerDay;
    //$("#nights-count").text(days);
    //$("#total").text(totalPrice);
    $("#nights-count").text($(this).val());
    $("#total").text($(this).val() * $(this).closest(".tour").data('daily-price'));
  });
});

Codeschool Sample Solution Keyup Event Handler I


$(document).ready(function() {
  $("#nights").on("keyup", function() {
    $("#nights-count").text($(this).val());
  });
});

Codeschool Sample Solution Keyup Event


$(document).ready(function() {
  $("#nights").on('keyup', function(){
  });
});

Codeschool Sample Solution Mouseleave


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
  $(".photos").on("mouseenter", "li", function() {
    $(this).find("span").slideToggle();
  });
  $(".photos").on("mouseleave", "li", function() {
    $(this).find("span").slideToggle();
  });
});

Thursday, June 6, 2013

Codeschool Sample Solution Mouseover II


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
  $(".photos").on("mouseenter", "li", function() {
    $(this).find("span").slideToggle();
  });
});

Codeschool Sample Solution Mouseover I


$(document).ready(function() {
  $("#tour").on('click', 'button', function() {
    $(".photos").slideToggle();
  });
 
  $(".photos").on('mouseenter', 'li', function(){
   
  });
});

Codeschool Sample Solution Slide Effect II


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $(".photos").slideToggle();
  });
});

Codeschool Sample Solution Slide Effect I


$(document).ready(function() {
  $("#tour").on("click", "button", function() {
    $('.photos').slideDown();
  });
});

Codeschool Sample Solution On Load II


$(document).ready(function() {
  $('#tour').on('click', 'button', function(){
    alert('I was clicked!');
  });
});

Codeschool Sample Solution On Load I


$(document).ready(function(){
  var numPhotos = $('img').length;
  alert(numPhotos);
});

Codeschool Sample Solution New Filter III


$(document).ready(function(){
  $("#filters").on("click", ".on-sale", function(){
    $(".highlight").removeClass();
    $(".tour").filter(".on-sale").addClass("highlight");
  });

  $("#filters").on("click", ".featured", function(){
    $(".highlight").removeClass();
    $(".tour").filter(".featured").addClass("highlight");
  });
});

Codeschool Sample Solution New Filter II


$(document).ready(function(){
  $("#filters").on("click", ".on-sale", function(){
    $(".tour").filter(".on-sale").addClass("highlight");
  });
});

Codeschool Sample Solution New Filter I


$(document).ready(function(){
  //Create the click handler here
  $("#filters").on("click", ".on-sale", function(){
  });
});

Codeschool Sample Solution Better On Handlers


$(document).ready(function(){
  $(".tour").on("click","button", function(){
    var tour = $(this).closest(".tour");
    var discount = tour.data("discount");
    var message = $("<span>Call 1-555-jquery-air for a $" + discount + "</span>");
    tour.append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Refactoring


$(document).ready(function(){
  $("button").on("click", function(){
    var tour = $(this).closest(".tour");
    var discount = tour.data("discount");
    var message = $("<span>Call 1-555-jquery-air for a $" + discount + "</span>");
    tour.append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Fetching Data from the DOM II


$(document).ready(function(){
  $("button").on("click", function(){
    var discount = $(this).closest(".tour").data("discount");
    //alert(discount); //for checking
    var message = $("<span>Call 1-555-jquery-air for a $"+discount+" discount</span>");
    $(this).closest(".tour").append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Fetching Data from DOM I


$(document).ready(function(){
  $('button').on('click', function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    var discount = $(this).closest(".tour").data("discount");
    $(this).closest(".tour").append(message);
    $(this).remove();
    //alert(discount); //prove that value of data is stored in var discount
  });
});

Codeschool Sample Solution Relative Traversing III


$(document).ready(function(){
  $(".tour").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).closest(".tour").append(message);
    $(this).find(".book").remove();
  });
});

Codeschool Sample Solution Traversing II


$(document).ready(function(){
  $('button').on('click', function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).closest("li").append(message);
    $(this).remove();
  });
});

Codeschool Sample Solution Relative Traversing I


$(document).ready(function(){
  $("button").on("click", function(){
    var message = $("<span>Call 1-555-jquery-air to book this tour</span>");
    $(this).parent().append(message);
    $(this).remove();
  });
});


This is an example of scrolling text using Javascript.

Popular Posts