How to write \ symbol in math mode in LaTeX/MathJax?

You probably want to use the backslash to exclude elements from a set. To this end use \setminus. To get the set of all integers without zero, you'd write

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
$\mathbb{Z} \setminus \{ 0 \}$
\end{document}

enter image description here

Also works in MathJax. Live example: http://mathb.in/29559


I often prefer to use \smallsetminus because the slash is lower down.

In this link http://docs.mathjax.org/en/latest/tex.html. I have seen that there is a possibility of using it with MathJax.

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
$\mathbb{R}\smallsetminus\{0\}$
\end{document}

enter image description here