Question: I am trying to get div value using jquery in chrome console from this:

```
<div class="col-md-3">
  <div class="vou-col" style="cursor: pointer">
    <h4>Free Large Bucket</h4>
    <span class="sku-info">Voucher123</span>
  </div>
</div>

```

I am getting the following error:

**$('.sku-info').val()**

VM783:1 

> 
> Uncaught TypeError: $(...).val is not a function
>  at :1:21
> 
> 
>

Answer: 
The Problems
------------

`.val()` is used to get the value of an **input** element - i.e. what the user has typed into a text box. It won't work for this purpose.

However, it should still be defined, even if called on an HTML element (it would still return `null`, though, so you would still have a problem). The only reason for `.val()` to be *not a function* would be if you had not included jQuery - insure that you have a line like

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

```

in the `<head>` section of your webpage to include jQuery, otherwise none of the solutions below will work either.

The Solution
------------

You want to get the internal HTML value of a `<div>`. So, you should use [`.text()`](http://api.jquery.com/text/) or [`.html()`](http://api.jquery.com/html/) instead of `.val()`.

* `.text()` will return the text in the `<div>`, without any HTML tags;
* `.html()` will return all of the content of the `<div>`, including any HTML tags inside it.

Example
-------

```js
console.log($(".sku-info").text())
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="col-md-3">
    <div class="vou-col" style="cursor: pointer">
        <h4>Free Large Bucket</h4>
        <span class="sku-info">Voucher123</span>
    </div>
</div>
```
include jquery

```js
var spanval = $('.sku-info').html();
alert(spanval);
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-3">
   <div class="vou-col" style="cursor: pointer">
       <h4>Free Large Bucket</h4>
        <span class="sku-info">Voucher123</span>
     </div>
 </div>
```