esc_js


esc_js ( $text )

Parameters:
  • (string) text The text to be escaped.
Returns:
  • (string) Escaped text.
Defined at:

Description

Escapes single quotes, `"`, `<`, `>`, `&`, and fixes line endings.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 {@see 'js_escape'} filter is also applied here.

Related Functions

esc_sql, esc_url, esc_xml, esc_attr, esc_html

Top Google Results

User discussions

wpseek mobile