I am wondering if someone can spot the mistake in my code?

javascript:

```
function decodehtml(thestring){
    var decoded = $("<div/>").html(thestring).text();
    alert(decoded);
    return decoded;
}

```

inside html:

```
<script type="text/javascript">
decodehtml("test&#32;string");
</script>

```

I know it is both returning and alerting, the alert is in there just for the test. For some reason this is doing nothing.

Any ideas?
Simon

Edit:

Even placing this directly into the html does not work:

```
<script type="text/javascript">
var decoded = $("<div/>").html("test&#32;string").text();
alert(decoded);
</script>

```