esc_js


esc_js ( $text )

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

Description

Escape single quotes, htmlspecialchar " < > &, and fix 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_html, esc_attr, fetch_rss

Top Google Results

User discussions

wpseek mobile