Side navigation
#13570 closed bug (notabug)
Opened March 06, 2013 07:01AM UTC
Closed March 13, 2013 12:48AM UTC
error in the description: addClass
| Reported by: | q13m@ya.ru | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | git |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
http://api.jquery.com/addClass/
<script type="text/javascript">
$(document).ready(function(){
$("ul li:last").addClass(function(index) {
return "item-" + index;
});
$("ul li").each(function(){
alert($(this).attr('class'));
});
});
</script>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
"Given an unordered list with five <li> elements, this example adds the class "item-4" to the last <li>."
not "item-4" -> "item-0"
This is expected, indexes go from 0. What did you expect? Also, if you think that something is broken, don't just paste code here but go to jsfiddle.net and create a test case that clearly states what you expect and demonstrates that it doesn't to that.