<!-- html -->
<h1>Title 1</h1>
<p>paragraph 1</p>
<p>paragraph 2</p>
<p>paragraph 3</p>
<h1>Title 2</h1>
<p>paragraph 1</p>
<p>paragraph 2</p>
<p>paragraph 3</p>
<!--jQuery -->
$('#numPara').bind('click', function(){
var i=0;
var bouton = $(this);
$('p').nextUntil('h1').each(function(index, element){
console.log(element);
$(element).prepend((index+1) + '.' + (index+1) + " ");
bouton.attr('disabled', false);
});
});
});
Question: How can I number the paragraphs from the number of the title? I already 'bind' my button to number the paragraphs but it doesn't apply on the first paragraph of each section and it doesn't follow the number of the title. Teacher told me that I should put limits but I've been searching for a few hours now and I have no idea how to do it. Thank you for any help.
Example : 1. Title1
1.1 paragraph1
1.2 paragraph2
1.3 paragraph3
2. Title2
2.1 paragraph1
2.2 paragraph2
2.3 paragraph3
` and `- `
– falsarella May 07 '13 at 16:39