Add “inview” event to jQuery. To detect if an element appears in the user viewport.
Have you ever thought about how can you take a picture from a user’s webcam? Here is a simple plugin for jQuery, which lets you control the webcam through javascript, and requires only that you place a small flash object in the web page.
Via xarg.org
A lot of developer actually use wp_head to insert scripts in a wordpress theme, but the correct way is use wp_enqueue_script.
This is to include jquery:
wp_enqueue_script('jquery');
If you want to include a different version of jQuery you can use these lines of code in your -theme-/functions.php or in your plugin:
<?php function my_init_method() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://code.jquery.com/jquery-1.4.2.min.js'); } add_action('init', 'my_init_method'); ?>
There are two common used jQuery CDN for jQuery:
http://code.jquery.com/jquery-1.4.2.min.js
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
Links
wp_enqueue_script: Function Reference/wp enqueue script
jQuery CDN URLs: http://docs.jquery.com/Downloading_jQuery
jQuery.scrollTo() is a plugin to scroll gracefully throught an HTML element, using the common jQuery element selector’s engine.
Usage:
jQuery.scrollTo("#css_selector", 400);
Official page: jQuery.ScrollTo.
Documentation: Project Intro
A Remy Sharp‘s blog post that try to answer to the crucial question:
How do you know if the plugin is good to use?
The ZURB jQuery Annotation is a useful plugin for easily annotate (and afterwards retrieve) position of user-defined points on an image.
Lazy loader is a jQuery plugin written in JavaScript. It delays loading of images in (long) web pages. Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them. This is opposite of image preloading.
Using lazy load on long web pages containing many large images makes the page load faster. Browser will be in ready state after loading visible images. In some cases it can also help to reduce server load.
via Lazy Load Plugin for jQuery.
There is also a WordPress plugin.
The method you can use to count the element’s of a jQuery selection is “size()”
$("div.class").size();
So you are able to do
if ($("div.class").size() > 0) // Do something else // Another thing
or whatever you want to do