Return to Snippet

Revision: 17609
at September 10, 2009 11:20 by joe-bbb


Updated Code
function mouse_overs (hover_item, css_property, hover_value, orig_value) {

	hover_item = $(hover_item);

	var new_obj = {};
	new_obj[css_property] = hover_value;

	var orig_obj = {};
	orig_obj[css_property] = orig_value;

	if (hover_item.length > 0) {
		hover_item.hover(
			function () { 
				$(this).css(new_obj); 
			}, 
			function () { 
				$(this).css(orig_obj);
			});
	}
}

$(function(){
    mouse_overs('button.link', 'background-position', '0 -43px', '0 0'); 
});

Revision: 17608
at September 10, 2009 10:46 by joe-bbb


Updated Code
function mouseOvers (hoverItem, cssProperty, hoverValue, origValue) {

	hoverItem = $(hoverItem);

	var new_obj = {};
	new_obj[cssProperty] = hoverValue;

	var orig_obj = {};
	orig_obj[cssProperty] = origValue;

	if (hoverItem.length > 0) {
		hoverItem.hover(
			function () { 
				$(this).css(new_obj); 
			}, 
			function () { $(this).css(orig_obj);
			});
	}
}


$(function(){
	mouseOvers('button.link', 'background-position', '0 -43px', '0 0'); 
});

Revision: 17607
at September 10, 2009 09:28 by joe-bbb


Initial Code
function mouseOvers (hoverItem, hoverValue, origValue) {

	hoverItem = $(hoverItem);

	if (hoverItem.length > 0) {
		hoverItem.hover(
			function () {
				$(this).css({ 'background' : hoverValue }); }, 
				function () { $(this).css({ 'background' : origValue });
		});
	}

 }

$(function(){
	mouseOvers('button.submit', 'url(/assets/images/go-hover.gif) no-repeat', 'url(/assets/images/go.gif) no-repeat'); 
});

Initial URL

                                

Initial Description

                                

Initial Title
hover - reusable arguments changing css object

Initial Tags

                                

Initial Language
jQuery