jQuery: Get selected element tag name

You can call .prop(“tagName”). Examples: If writing out .prop(“tagName”) is tedious, you can create a custom function like so: Examples: Note that tag names are, by convention, returned CAPITALIZED. If you want the returned tag name to be all lowercase, you can edit the custom function like so: Examples:

How to sort an array of integers correctly

By default, the sort method sorts elements alphabetically. To sort numerically just add a new method which handles numeric sorts (sortNumber, shown below) – Documentation: Mozilla Array.prototype.sort() recommends this compare function for arrays that don’t contain Infinity or NaN. (Because Infinity – Infinity is NaN, not 0). Also examples of sorting objects by key.

Syntax error: Illegal return statement in JavaScript

return only makes sense inside a function. There is no function in your code. Also, your code is worthy if the Department of Redundancy Department. Assuming you move it to a proper function, this would be better: EDIT much much later: Changed code to use json_encode to ensure the message contents don’t break just because of an apostrophe … Read more

JavaScript array to CSV

The cited answer was wrong. You had to change to As to why the cited answer was wrong (funny it has been accepted!): index, the second parameter of the forEach callback function, is the index in the looped-upon array, and it makes no sense to compare this to the size of infoArray, which is an … Read more