user-defined.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. $(document).ready(function () {
  2. 数据提交 = function(name = '地址',json = '数据',result = '回调') {
  3. $.post('http://localhost:13131/'+name,json,function(data){
  4. result(data);
  5. })
  6. }
  7. 文字渐显_循环 = function (table = '标签',value = '内容',time = '时间') {
  8. let i = 0;
  9. setInterval(function () {
  10. if (i === value.length){
  11. $(table).empty();
  12. i=0;
  13. }
  14. $(table).append(value[i]);
  15. i++;
  16. },time);
  17. }
  18. 文字渐显_单次 = function (table = '标签',value = '内容',time = '时间') {
  19. let i = 0;
  20. let j = setInterval(function () {
  21. if (i === value.length){
  22. clearInterval(j);
  23. }
  24. $(table).append(value[i]);
  25. i++;
  26. },time);
  27. }
  28. 滑动显示 = function (table1 = '标签一',time = '时间') {
  29. $(table1).css({
  30. overflow:'hidden',
  31. cursor:'pointer',
  32. }).find('div').css({
  33. width:$(table1).width(),
  34. height:$(table1).height(),
  35. background:'rgba(44,62,80,.4)',
  36. marginTop:$(table1).height()-$(table1).find('span').height(),
  37. cursor:'pointer',
  38. }).find('*').css({
  39. width:$(table1).width(),
  40. color:'#FFF',
  41. margin:'5px',
  42. textAlign:'left',
  43. });
  44. $(table1).hover(function(){
  45. $(this).find('div').animate({
  46. marginTop:'0px',
  47. },time)
  48. },function(){
  49. $(this).find('div').animate({
  50. marginTop:$(this).height()-$(this).find('span').height(),
  51. },time);
  52. });
  53. }
  54. alert_s = function(value = '类容'){
  55. $('body').append(`
  56. <div id="alert" style="background:transparent;
  57. left:0px;
  58. right:0px;
  59. top:0px;
  60. bottom:0px;
  61. margin:auto;
  62. text-align: center;
  63. position:fixed;
  64. z-index:999999;">
  65. <div style="text-align: center;position:absolute;
  66. left:0px;right:0px;top:0px;bottom:0px;margin:auto;
  67. width:150px;height:35px;border-radius:5px;background: rgba(0,0,0,0.3)">
  68. <span style="height:35px;line-height:35px;color: #ffffff;font-size: 13px">${value}</span>
  69. </div>
  70. </div>`);
  71. setTimeout(function () {
  72. $('#alert').remove();
  73. },500)
  74. }
  75. }