hover - reusable arguments changing css object


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.