最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery中$this和$(this)的區(qū)別介紹(一看就懂)

 更新時(shí)間:2015年07月06日 09:29:05   投稿:junjie  
這篇文章主要介紹了jQuery中$this和$(this)的區(qū)別介紹(一看就懂),本文用簡(jiǎn)潔的語(yǔ)言講解了它們之間的區(qū)別,并給出了一個(gè)例子來(lái)說(shuō)明,需要的朋友可以參考下
// this其實(shí)是一個(gè)Html 元素。
// $this 只是個(gè)變量名,加$是為說(shuō)明其是個(gè)jquery對(duì)象。
// 而$(this)是個(gè)轉(zhuǎn)換,將this表示的dom對(duì)象轉(zhuǎn)為jquery對(duì)象,這樣就可以使用jquery提供的方法操作。


(function($){
	$.fn.hilight = function(options){
		debug(this);

		var defaults = {
			foreground: 'red',
			background: 'yellow'
		};

		var opts = $.extend({}, $.fn.hilight.defaults, options);

		return this.each(function() {
      // this其實(shí)是一個(gè)Html 元素。
      // $this 只是個(gè)變量名,加$是為說(shuō)明其是個(gè)jquery對(duì)象。
      // 而$(this)是個(gè)轉(zhuǎn)換,將this表示的dom對(duì)象轉(zhuǎn)為jquery對(duì)象,這樣就可以使用jquery提供的方法操作。
			$this = $(this);

			// build element specific options
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			// update element styles
			$this.css({
				backgroundColor: o.background,
				color: o.foreground
			});

			var markup = $this.html();
			// call our format function

			markup = $.fn.hilight.format(markup);

			$this.html(markup);
		});

	};


	// define our format function
	$.fn.hilight.format = function(txt) {
		return '<strong>' + txt + '</strong>';
	};


	// 插件的defaults
	$.fn.hilight.defaults = {
		foreground: 'red',
		background: 'yellow'
	};

	function debug($obj) {
		if (window.console && window.console.log){
			window.console.log('hilight selection count: ' + $obj.size());
		}
	};

})(jQuery)

相關(guān)文章

最新評(píng)論

乌恰县| 民和| 贵德县| 宁蒗| 沐川县| 龙井市| 西城区| 泗洪县| 炉霍县| 鸡泽县| 左贡县| 泸溪县| 正镶白旗| 宁安市| 铁力市| 东兴市| 东山县| 师宗县| 申扎县| 昌江| 望奎县| 昭苏县| 淮南市| 思南县| 汪清县| 九寨沟县| 财经| 北京市| 北流市| 台南市| 淮安市| 宜兰市| 北海市| 雷山县| 兴国县| 高台县| 舒城县| 禹州市| 绵竹市| 夏邑县| 鄂伦春自治旗|