Search

Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Sunday, August 31, 2008

สร้าง Effect Menu ด้วย jquery





$(document).ready(function(){
$("#nav-one li").hover(
function(){ $("ul", this).fadeIn("fast"); },
function() { }
);
if (document.all) {
$("#nav-one li").hoverClass ("sfHover");
}
});

$.fn.hoverClass = function(c) {
return this.each(function(){
$(this).hover(
function() { $(this).addClass(c); },
function() { $(this).removeClass(c); }
);
});
};




A hover method for simulating hovering (moving the mouse on, and off, an object). This is a custom method which provides an 'in' to a frequent task.

Whenever the mouse cursor is moved over a matched element, the first specified function is fired. Whenever the mouse moves off of the element, the second specified function fires. Additionally, checks are in place to see if the mouse is still within the specified element itself (for example, an image inside of a div), and if it is, it will continue to 'hover', and not move out (a common error in using a mouseout event handler).

Check box with Jquery

checkbox are to used when you want to let the visitor select one or more options. If I want to alert value of checkbox when I selected it. This code here to show below are to show alert box.
I using jquery.
 <input>="radio" name="rdio" value="a" checked="checked" />
<input>="radio" name="rdio" value="b" />
<input>="radio" name="rdio" value="c" />

$("input[@name='rdio']").change(function(){
if ($("input[@name='rdio']:checked").val() == 'a')
// Code for handling value 'a'
else if ($("input[@name='rdio']:checked").val() == 'b')
// Code for handling value 'b'
else
// Code for handling 'c'
});

source:http://www.techiegyan.com