The counterIncrement
property is usually used
together with the counterReset
property and the content
property.
The counterIncrement
property increments counter values.
counterIncrement |
Yes | Yes | Yes | Yes | Yes |
Return the counterIncrement property:
var v = object.style.counterIncrement
Set the counterIncrement property:
object.style.counterIncrement='none|id|initial|inherit'
id
sets
which counter to increment. The number sets the step that the counter will increment on each occurrence. Default Value: | none |
---|---|
Return Value: | A string representing the counter-increment property |
CSS Version | CSS2 |
The following code shows how to change the counterIncrement
property.
<!DOCTYPE html>
<html>
<head>
<style>
h1 {<!--from ww w . j a va2 s . c o m-->
counter-increment: section;
}
h1:before {
content: "Section " counter(section) " ";
}
</style>
</head>
<body>
<h1>HTML</h1>
<h1 id="myH1">CSS</h1>
<h1>CSS3</h1>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myH1").style.counterIncrement = "subsection";
}
</script>
</body>
</html>
The code above is rendered as follows: