Презентация Using jquery. Creating animations, working with graphics, and accessing data онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Using jquery. Creating animations, working with graphics, and accessing data абсолютно бесплатно. Урок-презентация на эту тему содержит всего 43 слайда. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Using jquery. Creating animations, working with graphics, and accessing data
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:43 слайда
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:2.15 MB
- Просмотров:84
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№11 слайд
![Sample lt script gt function](/documents_6/c10265397066e61b82f164c36c45efe6/img10.jpg)
Содержание слайда: Sample
<script>
function countClicks() {
localStorage.clickcount = (localStorage.clickcount) ? Number(localStorage.clickcount) + 1: 1;
update();
}
function update() {
target.innerHTML = localStorage.clickcount || 0;
}
</script>
<p>You have clicked the button <span id='target'></span> time(s).</p>
<button type="button" onclick="countClicks()">Count</button>
<script>
update();
</script>
№12 слайд
![jQuery Write Less, Do More](/documents_6/c10265397066e61b82f164c36c45efe6/img11.jpg)
Содержание слайда: jQuery: Write Less, Do More
Query is a fast, small, and feature-rich JavaScript library.
It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
jQuery is so popular that it often treated as an integral part of JavaScript but actually it isn't.
№13 слайд
![Linking jQuery jQuery is](/documents_6/c10265397066e61b82f164c36c45efe6/img12.jpg)
Содержание слайда: Linking jQuery
jQuery is available at official website: http://jQuery.com
You may download jQuery to local folder but it is recommended to use CDN link. There is an official CDN from jQuery but also there are alternate CDN's from Google, Microsoft and other companies.
jQuery CDN link from http://code.jquery.com:
<script src='//code.jquery.com/jquery-2.1.1.min.js'></script>
Important notes:
always to link to some specific version of jQuery but not to most recent version without number, as it may break your project because of future changes;
to accelerate page load use minified version of the library, you may link to uncompressed library while developing project to make code debugging possible;
CDN link shown above does not include protocol, it means that current protocol (http or https) will be used, but it will fail if html page loads locally, so it is better sometimes to add protocol to link
№15 слайд
![Basic jQuery Syntax jQuery](/documents_6/c10265397066e61b82f164c36c45efe6/img14.jpg)
Содержание слайда: Basic jQuery Syntax
jQuery syntax is focused on selecting html elements and performing some actions on the elements
Basic syntax is: $(selector).action()
Comments:
A $ sign to define/access jQuery
A (selector) to 'query (or find)' HTML elements
A jQuery action() to be performed on the element(s)
№16 слайд
![window.onload Very common](/documents_6/c10265397066e61b82f164c36c45efe6/img15.jpg)
Содержание слайда: window.onload
Very common task in web programming is to run JS code when the browser finishes loading the document
To achieve this task a developer may attach code to window.onload event:
window.onload = function() {
alert( 'hello' );
}
Unfortunately, the code doesn't run until all images are finished downloading, including banner ads
№17 слайд
![jQuery Ready Event To run](/documents_6/c10265397066e61b82f164c36c45efe6/img16.jpg)
Содержание слайда: jQuery Ready Event
To run code as soon as the document is ready to be manipulated, jQuery has a statement known as the ready event
$(document).ready(function() {
alert('welcome');
});
This approach is preferred over assigning window.onload event handler
Alternative form (more preferred):
$(function() {
alert('welcome');
});
№18 слайд
![Basic Selectors jQuery](/documents_6/c10265397066e61b82f164c36c45efe6/img17.jpg)
Содержание слайда: Basic Selectors
jQuery selectors work same as CSS selectors
To select all <div> elements: $('div')
To select some specific element with id 'demo': $('#demo')
To select all elements with class 'demo': $('.demo')
Example: hide all <div> elements on target element click:
$(document).ready(function() {
$('#target').click(function(){
$('div').hide();
});
});
№19 слайд
![CSS Selectors jQuery allows](/documents_6/c10265397066e61b82f164c36c45efe6/img18.jpg)
Содержание слайда: CSS Selectors
jQuery allows to use same selectors as used in CSS versions 1-3
Incomplete list of some popular selectors:
'X + Y': adjacent selector, select only the element that is immediately preceded by the former element;
'X > Y': selects direct children of an element;
'X ~ Y': sibling combinator, similar to 'X + Y' but allows selection of element 'Y' even if it is not immediately follows 'X' but just follows it;
'X[title]': attribute selector, selects element 'X' if it has attribute 'title';
'X[title=value]': attribute value selector, selects element 'X' if it has attribute 'title' with value 'value'
Selector separated by comma treated as combination of selectors, selectors separated by space matched against descendants
For complete list of selectors see jQuery manual: http://api.jquery.com/category/selectors/
№20 слайд
![Reading and Changing HTML](/documents_6/c10265397066e61b82f164c36c45efe6/img19.jpg)
Содержание слайда: Reading and Changing HTML Contents
Method .html() allows to get or set HTML contents of elements
When used as getter this method does not accept arguments and return contents of the first element in the set of matched elements:
Sample: var htmlString = $('#mydiv').html();
When used as setter this method sets the HTML contents of each element in the set of matched elements. Any content that was in that element is completely replaced by the new content.
Sample: $('div').html('<p>Hello!</p>');
№21 слайд
![Reading and Changing Class](/documents_6/c10265397066e61b82f164c36c45efe6/img20.jpg)
Содержание слайда: Reading and Changing Class Info
jQuery allows to read, add or remove information about class for any element. This may be useful to change how elements shown based on predefined CSS styles assigned to the class and much more
These methods are:
.addClass() – adds class:
$('p').addClass('myClass');
.removeClass() – removes class:
$('p').removeClass('myClass');
.hasClass() – checks if class is assigned:
$('#myp').hasClass('myClass');
.toggleClass() – adds class if it is not assigned and vice versa: $('#myp').toggleClass('myClass');
These methods, like other methods of jQuery may be chained to each other:
$('p').removeClass('myClass noClass').addClass('yourClass');
№22 слайд
![jQuery Event Basics It is](/documents_6/c10265397066e61b82f164c36c45efe6/img21.jpg)
Содержание слайда: jQuery Event Basics
It is very convenient to use jQuery to set up event-driven responses on page elements.
These events are often triggered by the end user's interaction with the page, such as when text is entered into a form element or the mouse pointer is moved.
In some cases, such as the page load and unload events, the browser itself will trigger the event.
jQuery offers convenience methods for most native browser events. These methods are — including .click(), .focus(), .blur(), .change(), etc.
№24 слайд
![Setting Up Browser onclick](/documents_6/c10265397066e61b82f164c36c45efe6/img23.jpg)
Содержание слайда: Setting Up Browser onclick Event With .on() Method
Using .on() method we may setup any native browser event as well as custom events:
$( 'p' ).on( 'click', function() {
console.log( 'click' );
});
Or multiple events:
$( 'input' ).on('click change', // bind listeners for multiple events
function() {
console.log( 'An input was clicked or changed!' )
}
);
№25 слайд
![Showing and Hiding Content](/documents_6/c10265397066e61b82f164c36c45efe6/img24.jpg)
Содержание слайда: Showing and Hiding Content
jQuery can show or hide content instantaneously with .show() or .hide().
When jQuery hides an element, it sets its CSS display property to none. This means the content will have zero width and height; it does not mean that the content will simply become transparent and leave an empty area on the page.
// Instantaneously hide all paragraphs
$( 'p' ).hide();
// Instantaneously show all divs that have the hidden style class
$( 'div.hidden' ).show();
№26 слайд
![Animated Showing and Hiding](/documents_6/c10265397066e61b82f164c36c45efe6/img25.jpg)
Содержание слайда: Animated Showing and Hiding
jQuery can also show or hide content by means of animation effects.
Simplest way is to pass argument of 'slow', 'normal', or 'fast' to .show() and .hide() methods:
// Slowly hide all paragraphs
$( 'p' ).hide( 'slow' );
It is possible also to pass desired duration of animation in milliseconds:
// Show all divs that have the hidden style class over 0.5 sec
$( 'div.hidden' ).show( 500 );
№27 слайд
![Fade and Slide Animations](/documents_6/c10265397066e61b82f164c36c45efe6/img26.jpg)
Содержание слайда: Fade and Slide Animations
jQuery uses combination of fade and slide effects while showing and hiding elements. It is possible to use this effects separately.
Slide animation:
// Hide all paragraphs using a slide up animation over 0.8 seconds
$( 'p' ).slideUp( 800 );
// Show all hidden divs using a slide down animation over 0.6 seconds
$( 'div.hidden' ).slideDown( 600 );
Fade animation:
// Hide all paragraphs using a fade out animation over 1.5 seconds
$( 'p' ).fadeOut( 1500 );
// Show all hidden divs using a fade in animation over 0.75 seconds
$( 'div.hidden' ).fadeIn( 750 );
№28 слайд
![Changing Display Based on](/documents_6/c10265397066e61b82f164c36c45efe6/img27.jpg)
Содержание слайда: Changing Display Based on Current Visibility State
jQuery can also let you change a content's visibility based on its current visibility state. Method .toggle() will show content that is currently hidden and hide content that is currently visible. You can pass the same arguments to .toggle() as you pass to any of the effects methods above.
// Instantaneously toggle the display of all paragraphs
$( 'p' ).toggle();
// Slowly toggle the display of all images
$( 'img' ).toggle( 'slow' );
There are also .slideToggle() and .fadeToggle() methods:
// Toggle the display of all ordered lists over 1 second using slide up/down
$( 'ol' ).slideToggle( 1000 );
// Toggle the display of all blockquotes over 0.4 seconds using fade in/out
$( 'blockquote' ).fadeToggle( 400 );
№29 слайд
![Doing Something After an](/documents_6/c10265397066e61b82f164c36c45efe6/img28.jpg)
Содержание слайда: Doing Something After an Animation Completes
If we want to do something after animation completes, we can't use such code because it won't wait for completion:
// Incorrect: Fade in all hidden paragraphs; then add a style class to them $( 'p.hidden' ).fadeIn( 750 ).addClass( 'lookAtMe' );
To defer an action until after an animation has run to completion, you need to use an animation callback function. You can specify your animation callback as the second argument passed to any of the animation methods discussed above. For the code snippet above, we can implement a callback as follows:
// Fade in all hidden paragraphs; then add a style class to them
$( 'p.hidden' ).fadeIn( 750, function() {
// this = DOM element which has just finished being animated
$( this ).addClass( 'lookAtMe' );
});
№33 слайд
![What are Cookies? Cookies are](/documents_6/c10265397066e61b82f164c36c45efe6/img32.jpg)
Содержание слайда: What are Cookies?
Cookies are data, stored in small text files, on client computer.
There is a problem: when a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user.
Cookies were invented to solve the problem:
When a user visits a web page, his ID can be stored in a cookie.
Next time the user visits the page, the cookie "remembers" his ID
№34 слайд
![Create a Cookie with](/documents_6/c10265397066e61b82f164c36c45efe6/img33.jpg)
Содержание слайда: Create a Cookie with JavaScript
JavaScript can create, read, and delete cookies with the document.cookie property.
A cookie can be created like this:
document.cookie = "ID=123456789";
To save the cookie between browser sessions, we may add expiry date:
document.cookie = "ID=123456789; expires=Wed, 01 Jul 2015 12:00:00 GMT";
By default, cookie belongs to the page that created it, path parameter allows to set what path the cookie belong to:
document.cookie = "ID=123456789; expires=Wed, 01 Jul 2015 12:00:00 GMT; path=/";
№36 слайд
![Changing and Deleting Cookie](/documents_6/c10265397066e61b82f164c36c45efe6/img35.jpg)
Содержание слайда: Changing and Deleting Cookie
Changing cookie is made same way as creating it:
document.cookie = "ID=123456789; expires=Wed, 01 Jul 2015 12:00:00 GMT; path=/";
To delete a cookie we have to set expires parameter to a passed date:
document.cookie = "ID=123456789; expires=Thu, 01 Jan 1970 00:00:00 GMT";
№37 слайд
![Sample Function to Set a](/documents_6/c10265397066e61b82f164c36c45efe6/img36.jpg)
Содержание слайда: Sample Function to Set a Cookie
The parameters of the function above are the name of the cookie (cname), the value of the cookie (cvalue), and the number of days until the cookie should expire (exdays).
The function sets a cookie by adding together the cookiename, the cookie value, and the expires string.
№38 слайд
![Sample Function to Get a](/documents_6/c10265397066e61b82f164c36c45efe6/img37.jpg)
Содержание слайда: Sample Function to Get a Cookie
Take the cookiename as parameter (cname).
Create a variable (name) with the text to search for (cname + '=').
Split document.cookie on semicolons into an array called ca (ca = document.cookie.split(';')).
Loop through the ca array (i=0;i<ca.length;i++), and read out each value trimmed (c=ca[i].trim()).
If the cookie is found (c.indexOf(name) == 0), return the value of the cookie (c.substring(name.length,c.length).
If the cookie is not found, return ''.
№39 слайд
![Setting Up Events to Run Only](/documents_6/c10265397066e61b82f164c36c45efe6/img38.jpg)
Содержание слайда: Setting Up Events to Run Only Once
Sometimes you need a particular handler to run only once - after that, you may want no handler to run, or you may want a different handler to run.
jQuery provides the .one() method for this purpose:
// Switching handlers using the `$.fn.one` method
$( 'p' ).one( 'click', firstClick );
function firstClick() {
console.log( 'You just clicked this for the first time!' );
}
№40 слайд
![Tearing Down Event Listeners](/documents_6/c10265397066e61b82f164c36c45efe6/img39.jpg)
Содержание слайда: Tearing Down Event Listeners
To remove an event listener, you use the .off() method and pass in the event type to off.
// Tearing down all click handlers on a selection
$( 'p' ).off( 'click' );
If you attached a named function to the event, then you can isolate the event tear down to just that named function by passing it as the second argument.
№41 слайд
![Reading and Changing Styles](/documents_6/c10265397066e61b82f164c36c45efe6/img40.jpg)
Содержание слайда: Reading and Changing Styles
jQuery provides method .css() that allows to read or set style data.
If this method used as getter, it returns CSS property value of a first element that matches selector.
Syntax: .css('propertyName')
Sample: var color = $('#myDiv').css('background-color');
If this method used as setter, it sets CSS property values for all elements that match selector.
Syntax:
.css(propertyName, value); // value - a value to set for the property
.css(propertyName, function); // function - a function returning
// the value to set
.css(properties); // properties - an object of
// property-value pairs to set
№42 слайд
![Using Different Handlers for](/documents_6/c10265397066e61b82f164c36c45efe6/img41.jpg)
Содержание слайда: Using Different Handlers for Multiple Events
In the example below shown how to use different event handlers for multiple events:
// Binding multiple events with different handlers
$( 'p' ).on({
'click': function() { console.log( 'clicked!' ); },
'mouseover': function() { console.log( 'hovered!' ); }
});
Скачать все slide презентации Using jquery. Creating animations, working with graphics, and accessing data одним архивом:
Похожие презентации
-
OOP with C. Introduction C. Data Types. Variables, expressions, statements. C decision and iteration constructs
-
RhinoScript 101 Creativity "or how to do interesting things that are not easy to do with the mouse"
-
The Essence of C with examples in C84, C98, C11, and C14
-
HTML. The standard markup language for creating Web pages
-
Prolog. A general-purpose logic programming language associated with artificial intelligence and computational linguistics
-
Spring data. Familiar and consistent programming model for data access
-
Install Apache Cassandra on Ubuntu. Work with Cassandra and Python
-
Построение Standby Database на основе технологии Oracle Active Data Guard
-
Analysis and Design of Data Systems. Complex SQL Queries (Lecture 13)
-
Analysis and Design of Data Systems. Functional Dependencies and Normalization Theory (Lecture 15)