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: 
Your missing the quotes around the value of data-length. Correct your HTML markup like this:

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

```

Next, you do not want `val()` you want `data('length')`

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

```
If your `$length` variable's value in PHP will be output containing a comma, the first thing you have to do is correct your markup:

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

```

You need the quotes, so the result looks like this to the browser:

```
<td id="length" data-length="1,23" >

```

Then:

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

```

...should give you "1.23" in the log (given my example value above).

---

Perhaps worth noting: I'd avoid using the `id` value "length". That's just too common a word, and unfortunately the `id` namespace gets cluttered up with *all sorts of things*, particularly on IE. I'd go for something more unique.