Question: I have a string that contains an HTML code snippet and I want to get the value of the `id` attribute from the element `dt`.

```
var myHtml = "<dt id='119'>Email</dt><dd id='container'>my text</dd>";

```

Expected result:

```
var myId = 119;

```

Does anyone have any ideas how I can do this?

Answer: 
Simply can use `.attr()` 

```js
var myHtml = "<dt id='119'>Email</dt><dd id='container'>my text</dd>";
var myId = $(myHtml).first().attr('id');
alert(myId);
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
```
You can test this in console:

```
$("<dt id='119'>Email</dt><dd id='container'>my text</dd>").eq(0).attr('id')

```