<h1>order 属性</h1>

<div id="demo">
	<div class="item">
		<div class="view">order: <span>0</span> ;</div>
		<div class="controller">
			<a href="javascript:;" class="minus">-</a>
			<a href="javascript:;" class="plus">+</a>
		</div>
	</div>
	<div class="item">
		<div class="view">order: <span>0</span> ;</div>
		<div class="controller">
			<a href="javascript:;" class="minus">-</a>
			<a href="javascript:;" class="plus">+</a>
		</div>
	</div>
	<div class="item">
		<div class="view">order: <span>0</span> ;</div>
		<div class="controller">
			<a href="javascript:;" class="minus">-</a>
			<a href="javascript:;" class="plus">+</a>
		</div>
	</div>
	<div class="item">
		<div class="view">order: <span>0</span> ;</div>
		<div class="controller">
			<a href="javascript:;" class="minus">-</a>
			<a href="javascript:;" class="plus">+</a>
		</div>
	</div>
</div>
body{
	padding: 10px 30px 30px;
}
h1{
	text-align: center;
}
#controller{
	text-align: center;
	margin-bottom: 30px;
	font-size: 0;
	div{
		display: inline-block;
		font-size: 16px;
		margin: 0 5px;
	}
	span{
		display: inline-block;
		font-size: 12px;
		padding: 5px 10px;
		background-color: #ccc;
		color: #333;
		margin-right: 1px;
		cursor: pointer;
		&.selected{
			background-color: #06f;
			color: #fff;
		}
	}
}
#demo{
	display: flex;
	border: 1px solid;
	height: 150px;
	padding: 10px;
	counter-reset: items;
	.item{
		margin: 10px;
		padding: 20px 0;
		width: 200px;
		text-align: center;
		background-color: #ccc;
		counter-increment: items 1;
		&::before{
			content: 'item' counter(items);
		}
		&:nth-child(2){
			background-color: #f00;
		}
		&:nth-child(3){
			background-color: #0ff;
		}
		&:nth-child(4){
			background-color: #f0f;
		}
		.view{
			margin: 10px 0;
			span{
				font-weight: bold;
				padding: 2px 5px;
				background-color: #aaa;
			}
		}
		.controller{
			margin-top: 10px;
			a{
				display: inline-block;
				width: 30px;
				padding: 2px 0;
				text-align: center;
				text-decoration: none;
				background-color: #eee;
				color: #333;
				font-size: 12px;
				&:hover{
					background-color: #06f;
					color: #fff;
				}
			}
		}
	}
}
View Compiled
$('.controller a').click(function(){
	var $item = $(this).parents('.item');
	var val = ~~$item.find('.view span').text();
	if($(this).hasClass('minus')){
		val -= 1;
	}else{
		val += 1;
	}
	$item.find('.view span').text(val);
	$item.css('order', val);
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js