jQueryUI拖動(dòng)(Draggable)-事件

定義和用法

draggable 上的 start、drag 和 stop 事件。拖拽開始時(shí)觸發(fā) start 事件,拖拽期間觸發(fā) drag 事件,拖拽停止時(shí)觸發(fā) 
stop 事件

五原ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

示例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>jQuery UI 拖動(dòng)(Draggable) - 事件</title>
	<link rel="stylesheet" href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css">
	<style>
		#draggable{
			width: 16em;
			padding: 0 1em;
		}

		#draggable ul li{
			margin:1em 0;
			padding:0.5em 0;
		}

		#draggable ul li span.ui-icon{
			float: left;
		}

		#draggable ul li span.count{
			font-weight: bold;
		}
	</style>
</head>
<body>
	<div id="draggable" class="ui-widget ui-widget-content">
		<p>請(qǐng)拖拽我,觸發(fā)一連串的事件。</p>

		<ul class="ui-helper-reset">
			<li id="event-start" class="ui-state-default ui-corner-all">
				<span class="ui-icon ui-icon-play">"start" 被調(diào)用</span>
				<span class="count">0</span>x "start" 被調(diào)用
			</li>
			<li id="event-drag" class="ui-state-default ui-corner-all">
				<span class="ui-icon ui-icon-arrow-4">"drag" 被調(diào)用</span>
				<span class="count">0</span>x "drag" 被調(diào)用
			</li>
			<li id="event-stop" class="ui-state-default ui-corner-all">
				<span class="ui-icon ui-icon-stop">"stop" 被調(diào)用</span>
				<span class="count">0</span>x "stop" 被調(diào)用
			</li>
		</ul>
	</div>

	<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js" type="text/javascript" ></script>
	<script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
	<script>
		//獲取對(duì)象
		var $start_counter = $("#event-start"),
		$drag_counter = $("#event-drag"),
		$stop_counter = $("#event-stop"),
		counts = [0,0,0];

		$("#draggable").draggable({
			start:function(){
				counts[0]++;
				updateCounterStatus($start_counter,counts[0]);
			},
			drag:function(){
				counts[1]++;
				updateCounterStatus($drag_counter,counts[1]);
			},
			stop:function(){
				counts[2]++;
				updateCounterStatus($stop_counter,counts[2]);
			}
		});


		/**
		 * 更新數(shù)值
		 * @param  {[object]} $event_counter [li對(duì)象]
		 * @param  {[int]} new_count      [次數(shù)]
		 */
		function updateCounterStatus($event_counter,new_count){
			if (!$event_counter.hasClass('ui-state-hover')) {
				$event_counter.addClass('"ui-state-hover"')
				.siblings().removeClass('ui-state-hover');
			}

			$("span.count",$event_counter).text(new_count);
		}
	</script>
</body>
</html>

輸出

jQuery UI 拖動(dòng)(Draggable) - 事件

文章名稱:jQueryUI拖動(dòng)(Draggable)-事件
網(wǎng)頁網(wǎng)址:http://muchs.cn/article20/geedco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、ChatGPT、面包屑導(dǎo)航、搜索引擎優(yōu)化、自適應(yīng)網(wǎng)站、網(wǎng)站維護(hù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司