Search code examples
jquerytextareatextfieldencodehtmlspecialchars

Does jQuery encode special characters when using val('any text') on a Texfield, Textarea?


I'm confused about jQuerys val Function. It seems that it encode html special chars when set a value, but jQuerys Documentation tells nothing about.

Is this a Feature from jQuery or is it an internal Browser-Feature?


Solution

  • jsFiddle demo

    No, jQuery does not encode html special chars when setting a value with .val on a textarea or text input field.

    $("#d").val("&nbsp;!@#$%^&*()_+-=<>,./:';¿█");
    $("#t").val("&nbsp;!@#$%^&*()_+-=<>,./:';¿█");