How can I get name property of HTML element with jQuery?
Play around with this jsFiddle example:
HTML:
Hello, world!
jQuery:
$(function() {
var name = $('#foo').attr('name');
alert(name);
console.log(name);
});
This uses jQuery's .attr() method to get value for the first element in the matched set.
While not specifically jQuery, the result is shown as an alert prompt and written to the browser's console.