Question: I want to get a data from the element that i clicked using `this` in JavaScript?

but insisted of the data it's return `undefined`.

```js
function jj(){
    let yty = this.num;
    console.log(yty);
}
```

```css
li {
width:200px;
}
```

```html
<button num="2" onclick="jj()">3</button>
```

Answer: 
You need to pass `this` from HTML itself and use `getAttribute()` to get the attribute value you want

```js
function jj(btn) {
  console.log(btn.getAttribute('num'));
}
```

```css
li {
  width: 200px;
}
```

```html
<button num="2" onclick="jj(this)">3</button>
```
You can try the below code

```
<button num=2 onclick="getVal(event)">Click</button>

```

in .js

```
function getVal(event){
    let value=event.target.getAttribute('num');
    console.log(value);
}

```