秋霞韩国理伦电影在线观看hd,99re6这里只有精品地址,688欧美人禽杂交狂配,宝贝腿开大点我添添你视频男男

程序猿都要了解的35個 jQuery 小技巧(下)

作者:網(wǎng)站建設(shè)公司 來源:佛山網(wǎng)站建設(shè)日期:2020-11-11 瀏覽: 次

網(wǎng)站建設(shè) - 建站教程 - 網(wǎng)頁設(shè)計 - 程序猿都要了解的35個 jQuery 小技巧(下)

收集的35個 jQuery 小技巧/代碼片段,可以幫你快速開發(fā).


17.阻止鏈接加載


有時你不希望鏈接到某個頁面或者重新加載它,你可能希望它來做一些其他事情或者觸發(fā)一些其他腳本,你可以這么做:

$('a.no-link').click(function (e) {
  e.preventDefault();
});
18.切換 fade/slide

fade 和 slide 是我們在 jQuery 中經(jīng)常使用的動畫效果,它們可以使元素顯示效果更好。但是如果你希望元素顯示時使用種效果,而消失時使用第二種效果,則可以這么做:

// Fade
$('.btn').click(function () {
  $('.element').fadeToggle('slow');
});
// Toggle
$('.btn').click(function () {
  $('.element').slideToggle('slow');
});
19.簡單的手風(fēng)琴效果

這是一個實現(xiàn)手風(fēng)琴效果快速簡單的方法:

// Close all panels
$('#accordion').find('.content').hide();
// Accordion
$('#accordion').find('.accordion-header').click(function () {
  var next = $(this).next();
  next.slideToggle('fast');
  $('.content').not(next).slideUp('fast');  return false;
});
20.讓兩個 DIV 高度相同

有時你需要讓兩個 div 高度相同,而不管它們里面的內(nèi)容多少??梢允褂孟旅娴拇a片段:

var $columns = $('.column');var height = 0;
$columns.each(function () {
  if ($(this).height() > height) {
    height = $(this).height();
  }
});
$columns.height(height);
這段代碼會循環(huán)一組元素,并設(shè)置它們的高度為元素中的大高。
21. 驗證元素是否為空

This will allow you to check if an element is empty.

$(document).ready(function() {
  if ($('#id').html()) {
     // do something
   }
});
22. 替換元素

Want to replace a div, or something else?

$(document).ready(function() {
   $('#id').replaceWith('
<DIV>I have been replaced</DIV>

');
});
23. jQuery延時加載功能

Want to delay something?

$(document).ready(function() {
   window.setTimeout(function() {
        // do something
   }, 1000);
});
24. 移除單詞功能

Want to remove a certain word(s)?

$(document).ready(function() {
   var el = $('#id');
   el.html(el.html().replace(/word/ig, ""));
});
25. 驗證元素是否存在于jquery對象集合中

Simply test with the .length property if the element exists.

$(document).ready(function() {
   if ($('#id').length) {
     // do something
  }
});
26. 使整個DIV可點擊

Want to make the complete div clickable?

$(document).ready(function() {
    $("div").click(function(){
          //get the url from href attribute and launch the url
      window.location=$(this).find("a").attr("href"); return false;
    });// how to use<DIV><A href="index.html">home</A></DIV>});
27. ID與Class之間轉(zhuǎn)換

當(dāng)改變Window大小時,在ID與Class之間切換

$(document).ready(function() {
   function checkWindowSize() {
       if ( $(window).width() > 1200 ) {
        $('body').addClass('large');
    }    else {
        $('body').removeClass('large');
    }
   }
$(window).resize(checkWindowSize);
});
28. 克隆對象

Clone a div or an other element.

$(document).ready(function() {
   var cloned = $('#id').clone();// how to use<DIV id=id></DIV>});
29. 使元素居屏幕中間位置

Center an element in the center of your screen.

$(document).ready(function() {
  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;
  }
  $("#id").center();
});
30. 寫自己的選擇器

Write your own selectors.

$(document).ready(function() {
   $.extend($.expr[':'], {
       moreThen1000px: function(a) {
                  return $(a).width() > 1000;
      }
   });
  $('.box:moreThen1000px').click(function() {
        // creating a simple js alert box
      alert('The element that you have clicked is over 1000 pixels wide');
  });
});
31. 統(tǒng)計元素個數(shù)

Count an element.

$(document).ready(function() {
   $("p").size();
});
32. 使用自己的 Bullets

Want to use your own bullets instead of using the standard or images bullets?

$(document).ready(function() {
   $("ul").addClass("Replaced");
   $("ul > li").prepend("? "); // how to use
 ul.Replaced { list-style : none; }
});
33. 引用Google主機上的Jquery類庫

Let Google host the jQuery script for you. This can be done in 2 ways.

//Example 1
<SCRIPT src="http://www.cz22.cn/uploads/szweb/http://www.google.com/jsapi"></SCRIPT>
<SCRIPT type=text/javascript>
google.load("jquery", "1.2.6");
google.setOnLoadCallback(function() {
    // do something
});
</SCRIPT><SCRIPT type=text/javascript src="http://www.cz22.cn/uploads/szweb/http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></SCRIPT>
 // Example 2:(the best and fastest way)
<SCRIPT type=text/javascript src="http://www.cz22.cn/uploads/szweb/http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></SCRIPT>
34. 禁用Jquery(動畫)效果

Disable all jQuery effects

$(document).ready(function() {
    jQuery.fx.off = true;
});
35. 與其他Javascript類庫沖突解決方案

To avoid conflict other libraries on your website, you can use this jQuery Method, and assign a different variable name instead of the dollar sign.

$(document).ready(function() {
   var $jq = jQuery.noConflict();
   $jq('#id').show();

});


程序猿都要了解的35個 jQuery 小技巧(上)


企業(yè)網(wǎng)站建設(shè)一條龍
找零度飛易網(wǎng)絡(luò)公司-fslingdu所做php網(wǎng)站建設(shè)方案網(wǎng)站設(shè)計、網(wǎng)站制作北京上海深圳龍崗衢州蘭州常州東營南通濟寧桂林淮安煙臺長春無錫天津昆山蘇州合肥洛陽昆明天津唐山泉州惠州萬州新鄉(xiāng)商丘臺州哈爾濱太原攝影海口隨州學(xué)校商丘廣東湖南廣西江西海南廣州企業(yè)中小企業(yè)武漢南山羅湖福田虎門肇慶汕尾汕頭廣州佛山成都杭州濟南重慶福州西安廈門昆山沈陽青島徐州鄭州南京南寧長沙大連淄博石家莊南昌溫州珠海番禺順德三水高明中山東莞合肥江門嘉興西寧大良容桂倫教勒流陳村均安杏壇龍江樂從北滘祖廟石灣南莊等地區(qū)企業(yè)網(wǎng)站建設(shè)(廣告)公司提供專業(yè)做網(wǎng)站價格規(guī)劃書及營銷型網(wǎng)站制作,網(wǎng)站建設(shè)基礎(chǔ)知識

網(wǎng)站建設(shè)費用

網(wǎng)站制作電話:137 1543 1176

網(wǎng)站開發(fā)QQ:378780108

E-mailsale@fslingdu.com如何制作網(wǎng)站QQ :378780108

網(wǎng)站建設(shè)服務(wù)

網(wǎng)站建設(shè)公司零度飛易是一家專業(yè)網(wǎng)站設(shè)計,網(wǎng)站制作、seo優(yōu)化,網(wǎng)站推廣,網(wǎng)站建設(shè)的佛山網(wǎng)絡(luò)運營公司。零度飛易在家具網(wǎng)站建設(shè)小家電網(wǎng)站建設(shè)、服裝網(wǎng)站建設(shè)、電器網(wǎng)站建設(shè)、機械網(wǎng)站建設(shè)等行業(yè)的網(wǎng)站設(shè)計、網(wǎng)絡(luò)運營都得到行業(yè)認(rèn)可,在上海深圳、北京、廣州佛山、中山東莞地區(qū)有著良好的口碑品牌的網(wǎng)站建設(shè)公司。我們的使命是打造創(chuàng)新型的網(wǎng)站建設(shè)企業(yè),能輕易地開展“互聯(lián)網(wǎng)+”業(yè)務(wù)、實現(xiàn)“互聯(lián)網(wǎng)+企業(yè)”的企業(yè)愿景。

Hi,Are you ready?

準(zhǔn)備好開始了嗎?
那就與我們?nèi)〉寐?lián)系吧

有一個互聯(lián)網(wǎng)項目想和我們談?wù)剢??您可以填寫右邊的表格,讓我們了解您的項目需求,這是一個良好的開始,我們將會盡快與你取得聯(lián)系。當(dāng)然也歡迎您給我們寫信或是打電話,讓我們聽到你的聲音!

零度飛易 互聯(lián)網(wǎng)整合營銷

地址:佛山市順德區(qū)大良鳳翔商業(yè)廣場二座670

業(yè)務(wù)QQ:378780108

策劃專線:13715431176

E-mail:sale@fslingdu.com

合作意向表

您需要的服務(wù)

現(xiàn)有網(wǎng)站改版
我需要做微信營銷
建設(shè)全新的企業(yè)網(wǎng)站
要找長期合作公司,需要年度服務(wù)
我需要做購物商城
我需要做系統(tǒng)平臺

您最關(guān)注的地方

對功能要求比較高
對設(shè)計創(chuàng)意要求比較高
需要可以購物支付
搜索引擎排名

價格預(yù)算

1-3萬3-5萬5-8萬8-10萬10萬以上大型項目需要招標(biāo)