Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created November 5, 2016 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronpk/8e6d92c455cd3bce896b32eaecb714ed to your computer and use it in GitHub Desktop.
Save aaronpk/8e6d92c455cd3bce896b32eaecb714ed to your computer and use it in GitHub Desktop.
function addParagraphIDs() {
$("section").each(function(){
var section_id = $(this).attr("id");
var counter = 1;
$(this).find("p").each(function(){
var paragraph_id = section_id + "-p-" + counter;
counter++;
$(this).attr("id", paragraph_id);
});
var counter = 1;
$(this).find("li").each(function(){
var paragraph_id = section_id + "-li-" + counter;
counter++;
$(this).attr("id", paragraph_id);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment