Posted By

joe-bbb on 09/10/09


Tagged

hover arguments


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


hover - reusable arguments changing css object


 / Published in: jQuery
 

  1. function mouse_overs (hover_item, css_property, hover_value, orig_value) {
  2.  
  3. hover_item = $(hover_item);
  4.  
  5. var new_obj = {};
  6. new_obj[css_property] = hover_value;
  7.  
  8. var orig_obj = {};
  9. orig_obj[css_property] = orig_value;
  10.  
  11. if (hover_item.length > 0) {
  12. hover_item.hover(
  13. function () {
  14. $(this).css(new_obj);
  15. },
  16. function () {
  17. $(this).css(orig_obj);
  18. });
  19. }
  20. }
  21.  
  22. $(function(){
  23. mouse_overs('button.link', 'background-position', '0 -43px', '0 0');
  24. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: joe-bbb on September 11, 2009

This is pretty pointless for css, as addClass, would be cleaner and more efficient.

Posted By: joe-bbb on September 22, 2009

would come in more useful should these values change e.g. animate

You need to login to post a comment.