亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Handy and Useful jQuery Snippets for Develop

系統 2193 0

jQuery ?is a cross browser? JavaScript library ?that helps? developers ?and designers built and design powerful and? responsive ?web ?programs and? applications. ?It have actually made the coders? write less and do more with it.? jQuery ?is helpful in designing? page layout, ?adding application features and it?also provides capabilities for developers to create?plug-ins?on top of the? JavaScript library.

Handy and Useful jQuery Snippets for Developers

1. Preloading Images

      (function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }

jQuery.preLoadImages("image1.gif", "/path/to/image2.png");
    

Source

2. Hover on/off

      $("a").hover(
  function () {
    // code on hover over
  },
  function () {
    // code on away from hover
  }
);
    

Source

3. Smooth Scrolling to an anchor

      $(document).ready(function() {
	$("a.topLink").click(function() {
		$("html, body").animate({
			scrollTop: $($(this).attr("href")).offset().top + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});
});
    

Source

4. Fade in/out on hover

      $(document).ready(function(){
    $(".thumbs img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads

    $(".thumbs img").hover(function(){
        $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
    },function(){
        $(this).fadeTo("slow", 0.6); // This should set the opacity back to 60% on mouseout
    });
});
    

Source

5. ?Preventing anchor tags from loading

      $("a").on("click", function(e){
  e.preventDefault();
});
    

Source

6. Scroll to Top

      $("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});
    

Source

7.? Facebook ?like Image Gallery

      var nextimage = "/images/some-image.jpg";
$(document).ready(function(){
window.setTimeout(function(){
var img = $("
    

      ").attr("src", nextimage).load(function(){
//all done
});
}, 100);
});
    

Source

8. Auto Populating Select Boxes Using jQuery and Ajax

      $(function(){
$("select#ctlJob").change(function(){
$.getJSON("/select.php",{id: $(this).val(), ajax: 'true'}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '
' + j[i].optionDisplay + '

';
}
$("select#ctlPerson").html(options);
})
})
})
    

Source?

9. Auto Replace Broken Images

      // Safe Snippet
$("img").error(function () {
	$(this).unbind("error").attr("src", "missing_image.gif");
});

// Persistent Snipper
$("img").error(function () {
	$(this).attr("src", "missing_image.gif");
});
    

Source

10. Clear Form Data

      function clearForm(form) {
  // iterate over all of the inputs for the form
  // element that was passed in
  $(':input', form).each(function() {
    var type = this.type;
    var tag = this.tagName.toLowerCase(); // normalize case
    // it's ok to reset the value attr of text inputs,
    // password inputs, and textareas
    if (type == 'text' || type == 'password' || tag == 'textarea')
      this.value = "";
    // checkboxes and radios need to have their checked state cleared
    // but should *not* have their 'value' changed
    else if (type == 'checkbox' || type == 'radio')
      this.checked = false;
    // select elements need to have their 'selectedIndex' property set to -1
    // (this works for both single and multiple select elements)
    else if (tag == 'select')
      this.selectedIndex = -1;
  });
};
    

Source

Handy and Useful jQuery Snippets for Developers


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 77成人影视 | 自拍 欧美 在线 综合 另类 | 青草香蕉精品视频在线观看 | 久草视频在线网 | 婷婷操 | 欧美大尺度免费一级特黄 | 久久婷婷五夜综合色频 | 日韩欧美成人免费中文字幕 | 四虎在线最新永久免费 | 99热在线免费观看 | 日韩日b| 91青青青青青爽在线 | 99re热这里只有精品视频 | 欧美日韩在线网站 | 俺去鲁婷婷六月色综合 | 亚洲成人免费在线 | 久久精品国产曰本波多野结衣 | 国内精品久久久久影院6 | 神马影院我不卡在线观看 | 国产福利视频网站 | 国产精品分类视频分类一区 | 久久美 | 国产成人禁片免费观看 | 91在线精品亚洲一区二区 | 中文日韩字幕一区在线观看 | 99精品国产一区二区三区 | 天天躁日日躁狠狠躁中文字幕 | 九九国产| 视色视频| 99热这里只有精品4 99热这里只有精品5 | 美女被羞羞在线观看 | 欧美精品亚洲精品日韩专区va | 加勒比一本 | 亚洲欧美日本另类 | 国产一区二区精品久久岳 | 欧美日韩国产另类一区二区三区 | 一本大道高清香蕉中文大在线 | 久久er热这里只有精品23 | 中文字幕日本不卡一二三区 | 免费欧美一级片 | 999国产精品999久久久久久 |