example.js
上传用户:zhangwwang
上传日期:2022-07-20
资源大小:28k
文件大小:1k
源码类别:

JavaScript

开发平台:

Others

  1. var $el, $tempDiv, $tempButton, divHeight = 0;
  2. //Download by http://www.codefans.net
  3. $.fn.middleBoxButton = function(text, url) {
  4.     
  5.     return this.hover(function(e) {
  6.     
  7.         $el = $(this).css("border-color", "white");
  8.         divHeight = $el.height() + parseInt($el.css("padding-top")) + parseInt($el.css("padding-bottom"));
  9.                 
  10.         $tempDiv = $("<div />", {
  11.             "class": "overlay rounded"
  12.         });
  13.                 
  14.         $tempButton = $("<a />", {
  15.             "href": url,
  16.             "text": text,
  17.             "class": "widget-button rounded",
  18.             "css": {
  19.                 "top": (divHeight / 2) - 7 + "px"
  20.             }
  21.         }).appendTo($tempDiv);
  22.                 
  23.         $tempDiv.appendTo($el);
  24.         
  25.     }, function(e) {
  26.     
  27.         $el = $(this).css("border-color", "#999");
  28.     
  29.         $(".overlay").fadeOut("fast", function() {
  30.             $(this).remove();
  31.         })
  32.     
  33.     });
  34.     
  35. }
  36. $(function() {
  37.     
  38.     $(".widget-one").middleBoxButton("Read More", "#read");
  39.     $(".widget-two").middleBoxButton("Go to the Store", "#store");
  40.     $(".widget-three").middleBoxButton("Continue", "#more");
  41.     $(".widget-four").middleBoxButton("Behold!", "#bazinga");
  42. });