Question: Can you get the `id` attribute of a html tag using jQuery or without?

For example:

```
<ul id="todo" />

```

How can I get the `id`, without using `jQuery("#todo")`?

Is there a way for that? Will `attr()` work?

Answer: 
You can use `attr('id')` in jQuery or the `id` property (or `getAttribute('id')`) on the native DOM element.
`$('.class')[0].id` or `$('.class').get(0).id`

If you need this for multiple elements do

```
$('.class').each(function() {
    this.id
}

```

You can also use conventional `.attr` but it's slower. Though difference is not major, I don't see any drawbacks and syntax is basically same, unless you need to chain-edit attributes.