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>
```
**Problem**

It seems that your jQuery is running in no conflict mode - so `$` is the browser console's native function. This is often the case if using a version of jQuery which comes bundled with a CMS such as WordPress or Drupal. 

**Solution**

You can use the full version:

```
jQuery(".sku-value").text();

```

We can infer this is the case because the error is ".val(...) is not a function" - if it were jQuery then .val *would* be a function. 

**Useful debugging tip**

You can check to see if `$` is jQuery by seeing if it has a version number 

```
console.log($.fn.jquery)

```

If $ is jQuery then this will log a version number - something like "2.1.1". If $ jQuery is not jQuery, it'll log undefined.