Use jQuery/Javascript to create a list of all elements in a set
问题 I want to use Javascript to loop through a set of elements, and create a list of labels for each one, so if the set of elements were as follows: <h1>Title</h1> <h2>Subheading</h2> <p>Paragraph of text...</p> It would give me the following: <ol> <li>h1</li> <li>h2</li> <li>p</p> <ol> Is it possible for jQuery/Javascript to return an element's type as a string, and if so how would I go about it? 回答1: This is far from the cleanest piece of code I've ever done, but it works: function generateList