日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

收集的一些jQuery (我平常用的少的,但确实挺有效果的)

發(fā)布時間:2024/1/17 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 收集的一些jQuery (我平常用的少的,但确实挺有效果的) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

禁用Jquery(動畫)效果

jQuery.fx.off = true;

?

使用自己的 Bullets(這個有一丁點兒的小技巧)

//這里是js代碼 也就是給每個ul添加一個類名 然后給ul的子li前面添加html 你想要使用的Bullets $("ul").addClass("Replaced"); $("ul > li").prepend("? ");//在css里面這樣寫ul.Replaced { list-style : none; }

?

寫自己的選擇器

$.extend($.expr[':'], {moreThen1000px: function(a) {return $(a).width() > 1000;}});$('.box:moreThen1000px').click(function() {// creating a simple js alert boxalert('The element that you have clicked is over 1000 pixels wide');});

?

使元素屏幕居中

jQuery.fn.center = function () {this.css("position","absolute");this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");return this;} //寬度居中的位置應該就是窗口寬度減去當前元素寬度再除以2 最后減掉左部滾動寬度 高度同理 $("#id").center();

?

獲得鼠標指針XY值

$().mousemove(function(e){//display the x and y axis values inside the div with the id XY$('#XY').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);});

?

返回頁面頂部功能

$('a[href*=#]').click(function() {if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {//為什么會用replace呢 后來想想明白了 因為很多url里面會有雙重的/這樣replace之后再比較比如好var $target = $(this.hash);$target = $target.length && $target|| $('[name=' + this.hash.slice(1) +']');//寫這么晦澀的語法 意思就是說當前a元素的hash長度必須大于0并且不為undefined 則去找name等于獲得的hash值的元素if ($target.length) {var targetOffset = $target.offset().top;//獲得目標元素的高度$('html,body').animate({scrollTop: targetOffset}, 900);return false; } } });

?

在新窗口中打開鏈接

//Example 1: Every link will open in a new window$('a[href^="http://"]').attr("target", "_blank");//Example 2: Links with the rel="external" attribute will only open in a new window$('a[@rel$='external']').click(function(){this.target = "_blank";});

?

轉(zhuǎn)載于:https://www.cnblogs.com/liyunhua/p/4495536.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的收集的一些jQuery (我平常用的少的,但确实挺有效果的)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。