Question: I have a div like this : 

```
<td id="length" data-length=<?php echo $length;?> >

```

And I want to get the value of my php variable ($length) in a jquery script.

After that I have to format it to replace the comma with point.

With this snippet : 

```
var $length         = jQuery(this).find("#length");
console.log($length.data('length'));

```

I see read my variable in the console

but when I want to format it to replace the comma with a point like this :

```
console.log(parseFloat($length.val().replace(",", ".")));

```

I get NaN

Please help to solve that problem !

Answer: 
You're using `.val()` on a `<td>` instead of `.data()`.

```
 // Here you're using .data()
console.log($length.data('length'));

 // Here you're using .val() which is wrong.
console.log(parseFloat($length.val().replace(",", ".")));

```
Your code isn't quite right, you're trying to replace the comma in the jQuery object containing the `td#length` element, try this:

```
var length = $("#length").data("length");
console.log(parseFloat(length.replace(",",".");

```

Also, your HTML should include quotes around the value of each attribute, like this:

```
<td id="length" data-length="<?php echo $length;?>">

```