本文纯粹是贴出一些比较实用的代码出来供大家学习和使用,也算是个人博客对这些实用代码的记录和收集吧!有用到的可以参考,没用到的直接可以飘过!

特意将这些代码写成jQuery插件的格式,这样方便大家使用的时候调用。我在平时的开发和自我学习过程中也积累了不少有用的代码,不知道怎么概括性地发布出来,所以就已文章的形式陆续贴出来与大家分享。

以单篇文章发布的插件代码都是一些简单的代码,若是一些复杂的代码或插件我会归纳到插件专区里去,这样大家下载起来也方便!

一、插件代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;(function($) {

	$.extend({
		/**
		 * 调用方法: var timerArr = $.blinkTitle.show();
		 *			$.blinkTitle.clear(timerArr);
		 */
		blinkTitle : {
			show : function() {	//有新消息时在title处闪烁提示
				var step=0, _title = document.title;

				var timer = setInterval(function() {
					step++;
					if (step==3) {step=1};
					if (step==1) {document.title='【   】'+_title};
					if (step==2) {document.title='【新消息】'+_title};
				}, 500);

				return [timer, _title];
			},

			/**
			 * @param timerArr[0], timer标记
			 * @param timerArr[1], 初始的title文本内容
			 */
			clear : function(timerArr) {	//去除闪烁提示,恢复初始title文本
				if(timerArr) {
					clearInterval(timerArr[0]);
					document.title = timerArr[1];
				};
			}
		}
	});
})(jQuery);

注意其中调用方法中的timerArr变量,若你在前面调用代码显示了效果,在页面的后面代码中需要清楚该闪烁效果的话,需要注意timerArr变量的作用域。若只是出现效果而无需清楚,则可以直接调用$.hiro.blinkNews.show()

二、调用方法

1
2
3
4
5
6
7
8
9
jQuery(function($) {
	var timerArr = $.blinkTitle.show();

	setTimeout(function() {		//此处是过一定时间后自动消失
		$.blinkTitle.clear(timerArr);
	}, 10000);

	//若人为操作消失,只需如此调用:	$.blinkTitle.clear(timerArr);

jQuery并不像他表面显示的那样,只有那些额定的方法供我们使用。其他在他库的代码内有着很多很酷很便捷的潜在方法,等待被我们发现。在本文中,我将带领你去领略一些我在jQuery库中发现的那些不怎么常见的方法。

1.理解jQuery方法:

当你调用jQuery方法时会发生什么呢?看看jQuery的方法体,非常地简单。

1
2
3
4
jQuery = function (selector, context) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init(selector, context);
};

在表层的代码之下,jQuery方法(通常称之为“包装”方法)将返回一个实例化后的jQuery对象,即’jQuery.fn.init’构造函数的一个实例。

理解了这一点非常有用,当我们每次调用jQuery方法时,都会返回一个带有一组属性的完全独立的对象。而jQuery的聪明之处在于返回的这个对象是以数组的方式返回的。该对象中的所有元素(通称”集合“)都是由一个数字索引所指向,就像数组中的下标一样。而且jQuery还返回了一个对象的length属性,就像数组中的长度一样。这种思想给jQuery方法提供了无限的想象空间。比如,我们可以从’Array.prototype’中借用一些功能性方法。jQuery中的slice方法就是一个典型的例子:

1
2
3
4
5
6
7
8
9
10
/* ... jQuery.fn.extend({ ... */
slice: function() {
    return this.pushStack(
        Array.prototype.slice.apply( this, arguments ),
        "slice",
        Array.prototype.slice.call(<wbr>arguments).join(",")
    );
},
/* ... */
</wbr>

在该slice方法不管this是否是一个真实的数组,它和其他的元素会和睦地相处,因为有着”length“这么一个属性。

jQuery中还有一些其他有趣的属性,比如”selector”—选择器,”context”—-上下文等。大部分的时候,只需给jQuery方法传递对象参数即可:

1
2
var jqObject = jQuery('a');
jqObject.selector; // => "a"

一个重要的提示是,jQuery有时会返回一个全新的对象供你使用。比如你试图通过执行一段代码来改变一个集合,如”parent()”方法,但是此时jQuery将不会修改当前的对象,它会返回给你一个全新的对象。

1
2
3
4
var originalObject = jQuery('a');
var anotherObject = originalObject.parents();

originalObject === anotherObject; // => false

所有试图改变集合的方法都会返回一个新的jQuery对象,你可以通过”.end()”方法或”.prevObject”属性来访问之前的那个对象。

近段时间来访问我博客的博友们不知是否注意到,博客的一些地方添加了一些增强型Ajax加载效果,用以提高访客的交互和快速浏览不同分类、标签下最新的文章列表。而在今天又新增了增强型Ajax提交评论和回复,只要你留言你就会看到具体效果。

下面我对几处增强Ajax效果进行一下具体说明,大家以后访问我博客时也可以适当地使用。之所以说是增强型Ajax效果,是因为我并没有改变原先的代码,而是在原始代码基础上添加了jQuery控制,这样即使jQuery代码没有加载完成时,你也可以访问到相应的页面。

1.Ajax加载历史文章列表:

在博客的右边有一个最新文章板块,大家可以看到在标题的右边有上页、下页的链接,点击相应的链接便可Ajax加载上下页的文章列表,每次加载10条。图:

2.分类Ajax加载相关最新10条文章记录:

点击博客左边的每个摘要型Post的分类链接、博客右边的分类目录版块链接或者每篇完整型文章的分类链接。会出现一个loading的shadow层,加载完成后罗列出该分类下的最新文章。图:

3.标签Ajax加载相关最新10条文章记录:

点击博客左边的每个摘要型Post的标签链接、博客右边的热门标签版块链接或者每篇完整型文章的标签链接。同样会出现一个loading的shadow层,加载完成后罗列出该标签下的最新文章。图:

4.Ajax提交评论和回复别人的留言:

在此之前,没此提交评论后,当前页面都要重新加载一次,很是耗时。添加Ajax评论后,速度会更快,也大量减少了请求。我的博客一直只提供2层回复。不喜欢多层次回复,看着很难受!具体Ajax评论效果大家只需留言即可看到。

花了精力添加这些Ajax效果,无非是为了让各位博友和来访者可以更加方便地阅读我的博客,同时也希望大家可以多多给我意见。每次添加新的功能我都会在左边的蓝条里写出来,大家可以一目了然地看到我最新的修改信息。

When it comes to your water supply, you can not take way too many opportunities. You would like to know that the water entering into your house is risk-free for drinking which all components of you water supply is made to last. This is why it is so essential to raise your water pump’s life expectancy with PUB approved gaskets. Doing so first could conserve you a lot of concerns later.

The Importance of High Quality Gaskets

In addition to, bath time when you have to drag in all that water and reuse water that has actually been bathed in previously. It may have worked at one time, yet that doesn’t suggest we need to make every effort to do it in today’s world. Rather, a better choice is to pick premium quality wells with even higher quality inside components such as the rubber gaskets that produce the strong seal that avoids water seepage. In short, it offers the water that is needed for your house or your service to run effectively.

The cooking area may be the heart of your home, but without an excellent water supply supplying water, you would not appreciate spending you time preparing meals and also such. You would certainly be forced to still head out to the well or the river to gather water by the container lots. Where’s the fun because?

Alternative Options?

You may be asking suppose it isn’t Public Utilities Board authorized? Or a selection that is accepted by the Public Utilities Board. The reality is you shouldn’t utilize it. When you pick anything else, it may not be suitable for drinkable, or drinkable, water. Primarily, it would benefit flushing a bathroom, however very little else. This kind of makes indoor pipes a little trickier.

Considering the majority of us have a single water line, either from a city well or a nation well, that brings all water into our house, do not you desire it to be as safe as feasible? Functional for whatever you need to use it for? Many people feel that it is that important.

In our viewpoint, and also the viewpoint of most people, finding PUB approved as well as advised products is ideal. It enables you to know undeniably that you are giving your family members with the most effective feasible water to drink. It likewise permits you to know that you are not facing an imminent leakage anytime in the near future.

The net makes it simple for anyone who likes anime to visit a high-grade anime store at www.cosplayo.com. Through these shops, you can expect the softest, most comfortable styles available. All of which will enable you to show your love of this style of apparel easily. It doesn’t matter whether you’re a fan of Naruto, Uchiha, or any one of the other most prominent personalities.

You don’t need to use an anime t-shirt or hoodie with a real personality on it. You might pick a logo or particular colors instead. Anime designs are all about what makes you comfy. You can go just as far as you want to go with it. There are some who merely intend to show their faves. Others wish to clothe the component. What do you want to see on your own in? Or what would you such as to see your kid putting on?

An anime hoodie may have zippers. They might also be sweatshirts with a hood on them. You reach select what you like one of the most or what you think somebody else would certainly like the most. In our point of view, all are quite enjoyable to wear. They order the focus of others, even those who might not such as anime will certainly locate that they are drawn to the bold colors and also impressive, lifelike caricatures.

Show the world what you take pleasure in and be comfortable while doing it. That is the suggestion behind kawaii garments. They enable you to create your very own one-of-a-kind style and afterwards show it off to all who see you strolling down the street. A lot of these designs are affordable as well as look wonderful whether you are sprucing up or clothing down in a style that is distinctively yours. Are you prepared to examine it out?

No matter what you are searching for, there are kawaii clothing options. You can dress for cosplay with wigs, capes, as well as other outfits or accessories. You can clothe for every single day at college and when socializing with friends. These clothing and accessories make terrific presents, however they can likewise be things that you use on your own. The enjoyable of this garments style is that any individual can use it for any kind of reason. It makes a declaration and also sets you in addition to the crowd.

That does not love anime? It is the stuff that today’s kids see around them. They are cutely dressed characters with great hair. Some are brief spoofs and also others are exciting episodes or flicks. Their interest children as well as several grownups is undeniable. Most typically, it is the youngsters as well as teenagers that desire to use their preferred personalities on an anime hoodie. They do it to be cool, however they likewise wear them to express themselves.

The reality is, those who enjoy anime can not obtain sufficient of it. Those that dislike it, wonder what the allure of using garments that have anime personalities on it may be. It is a means for teenagers today to express themselves. Their likes, their favored points, and their favored clothing designs. It shows the things that they enjoy. It incorporates well with the largest trends of today. It is the one where you try to establish yourself apart as opposed to adhere to the group based on just how you clothe as well as what you feel is most comfortable.

Did you understand that there is an anime shop around with the most preferred hoodies and other clothes designs? It is there. There are several high-grade internet sites and stores available that aim to satisfy everybody’s demands. All that individual needs to do is wish to use the coolest clothing readily available. These clothing feature the most popular and also most favorite anime personalities. These hoodies, t shirts, hats, and other cosplay clothing are all assured to make every person delighted.

When you require an occasion space, a workshop could be optimal. These areas can be made use of for conferences, wedding celebrations, therefore a lot more. You can utilize them at any time that you desire a huge room that permits people to hear what is being claimed plainly or when you need to know that sound and also video will certainly come across plainly. Throughout a wedding, you never ever need to fret that somebody being in the back may not have the ability to hear the sacred swears that are being talked. In conferences, you never need to worry that somebody will certainly be left questioning what they missed. It’s a win-win situation for all.

When you think about studio space for rent in Singapore, you will certainly be offered with whatever you need for a successful event. This includes assistance to set it up, the exceptional audio as well as visual gadgets, and a room that is large sufficient for all that are most likely to participate in. For company conferences that run long, you can even expect to have easy access to a lounge, which is fantastic for taking a quick lunch break.

Organizing an occasion always requires a lot of different points. Thankfully, for individuals in Singapore, it is simpler to have every little thing you require without the responsibility to buy everything. It is less complicated to host an event when you have accessibility to a high-quality stereo, audio system, video clip system currently established for you. You can make use of a recording workshop space for rent and have ample to make your occasion, whether company or pleasure, a success.

If you have concerns with any one of the devices or establishing your event, there are additionally people nearby that can assist if you require it. When you make the most of a studio space for rent you acquire a lot of advantages. It is a space that you do not need to go trying to find. You likewise get to have very easy accessibility to as much room as you require and nothing even more. This implies you aren’t spending for wasted room. These studios are soundproof to give personal privacy and also they supply you with an area that is acoustically prepared for whatever you have actually planned.

What kind of event are you intending? Regardless of what your plans are, a studio rental in Singapore is probably the best option you have if you desire a location that is easy to get to for all individuals you are welcoming. In a workshop rental, you will certainly be able to satisfy, socialize, and learn en masse. If that does not satisfy your requirements, you can likewise celebrate in a studio. You can utilize it for any type of event any time. You get to pick what it is most valuable for.

There are studios available in various dimensions. Some can hold just a little team of people. Usually, the smallest workshop offered is one that can hold about 40 people. This is sufficient area to have simply a little group of choosing figures in your company. It might also be a great area for a business award event if you are just most likely to welcome the people that are earning an honor as well as their immediate family.

A studio space for rent in Singapore is best made use of for business conferences, but it can be utilized for a variety of events. The largest studios can hold roughly 120 people, that makes it optimal for smaller sized conferences and events where you do not have a lengthy list of guests. If you are anticipating more individuals, you may require to have a larger space, such as an amphitheater, which can additionally be rented out.

A tape-recording studio area for rent is not just for recording. The bonus offer of renting this room expands much past. It makes it easier for you to tape videos, which can later be utilized as presentations for others within your firm. The high-grade stereo will permit you or your guest speakers to be heard plainly. There are additionally superior visual aids offered to ensure that even presentations can be seen by all who are in attendance.

If you ask about, one of the primary factors individuals love on-line purchasing is the potential to locate sale things that they can not find locally. Typically, they save a great deal of cash by searching as well as looking for the products that they desire. You can do the very same. You can search the internet for offers on any type of furniture piece. Eventually, you will find the thing that you want, on sale, at an on-line quality furniture Singapore. If you are incapable to discover a good deal that makes it an inexpensive acquisition, you likewise have the choice to see a manufacturer’s internet site where you might have the ability to find a price cut.

One point people like about buying from an on-line shop is that every little thing they desire is supplied to their residence without additional costs as well as things added to the cost. Furniture is no different. You can purchase a room collection, a dining-room collection, lamps, or anything else as well as it will certainly be supplied. Even if you buy something that is extremely breakable, it will show up safely and you will never ever have to think of how to get it to your residence safe. That is the bonus to shopping via an on the internet furniture store Singapore.

When you choose to shop for furnishings online, you are most likely to have a much larger selection to choose from. There are a selection of products from all over that you can search. It does not matter whether you are searching for a huge item, such as your following bed room collection or something little like a table light. There are stores that deal specifically with furniture to ensure that you can discover precisely what you want at a rate that you feel is economical.

Computers are really beneficial tools for a great deal of things. With them, life ends up being less complicated and you no longer have to make phone calls or run errands if you are unable to do so. With your computer you can shop for clothing, medicine, playthings, and also furniture. Have you ever took a look at an online furnishings store Singapore? They use big selections at a budget-friendly rate, both of which can make revamping as basic as pressing a button.

As times adjustment as well as individuals age, it ends up being harder for them to venture out and shop for points. On the internet buying has actually made this easier for those people as well as their households. Buying from an online quality furniture Singapore by etch&bolts, is likewise beneficial. It allows the person to purchase brand-new points for their home to make sure that they are always comfortable within it.

When trying to find furnishings that fits your residence the method you desire for it to, you might have to spend time searching through an on the internet furnishings store Singapore. It will deserve it when it is supplied to your residence looking better than you ever before imagined it would certainly. You will discover how well it harmonizes the remainder of your furniture and also just how comfortable it is to remain on or easy it is to use. Once you do that, it will be a search that you will certainly rejoice you took your time one. This feeling will certainly be much more worth it when others see your brand-new furnishings and also say how wonderful it looks.

There are people throughout Singapore that produce distinct furniture pieces to give themselves something to do and permit them to make a little money on the side. They are all unique pieces that are handmade rather than equipment made. They are one of a kind and assured to improve the allure of any type of area within your home. Best of all, you can discover them on the internet, without understanding the person directly. This makes discovering a prize simple, despite where the neighborhood lives.

What type of furnishings do you feel that your house needs to make it a lot more full? What furniture have you always wanted? It is available waiting on you to find it. By checking out an online quality furniture Singapore, you can locate everything you desire. You can find points that your youngsters will certainly like as well as you find points that can make your entire household delight in family members time a bit extra, due to the included comfort and also design.