其他分享
首页 > 其他分享> > 一个css属性选择器的实际例子

一个css属性选择器的实际例子

作者:互联网

<html>
<style>

div {
	color: blue;
}

[tabindex="0"]{
	color: red;
}


[tabindex="1"]{
	color: green;
}

[tabindex="2"]{
	color: yellow;
}

</style>
<script>
function clickme(){
	var oButton = getButton();
	var newAttribute = add();
	oButton.setAttribute("tabindex", newAttribute);
}

function getButton(){
	return document.getElementById("jerry");
}

function getNewCountFactory(){
	var counter = 1;
	return function(){
		return (counter++) % 3;
	};
}

var add = getNewCountFactory();
</script>
<button onclick="clickme()">Add</button>
<div>1</div>
<div id="jerry" tabindex="1">2</div>
</html>

标签:function,getButton,return,color,var,tabindex,选择器,css,属性
来源: https://blog.csdn.net/i042416/article/details/112358025