esc_js( string $text )
Escapes single quotes, "
, <
, >
, &
, and fixes line endings.
Description
Escapes text strings for echoing in JS. It is intended to be used for inline JS (in a tag attribute, for example onclick="..."
). Note that the strings have to be in single quotes. The ‘js_escape’ filter is also applied here.
Parameters
- $text
-
(Required) The text to be escaped.
Return
(string) Escaped text.
Source
File: wp-includes/formatting.php
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |