I need to create some jQuery-Listings but when I try to do so
\documentclass[12pt,oneside,a4paper]{scrartcl}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{color}
\definecolor{lightgray}{rgb}{.9, .9, .9}
\definecolor{darkgray}{rgb}{.4, .4, .4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\lstdefinelanguage{JavaScript}{
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
keywordstyle=\color{blue}\bfseries,
ndkeywords={class, export, boolean, throw, implements, import, this},
ndkeywordstyle=\color{darkgray}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
commentstyle=\color{purple}\ttfamily,
stringstyle=\color{red}\ttfamily,
morestring=[b]',
morestring=[b]"}
\lstset{
language=JavaScript,
backgroundcolor=\color{lightgray},
extendedchars=true,
basicstyle=\footnotesize\ttfamily,
showstringspaces=false,
showspaces=false,
numbers=left,
numberstyle=\footnotesize\ttfamily,
numbersep=9pt,
tabsize=2,
breaklines=true,
showtabs=false,
frame=leftline,
caption=\lstname}
\begin{document}
\begin{lstlisting}[name=Beispiel mit JavaScript Bibliothek (jQuery)]
\$("p").elements.each(function() {
\$(this).html = "Element erkannt";
});
\end{lstlisting}
\end{document}
The $ doesn't get displayed. If I try to escape it normally using \$("#test"), it ends up looking like \ ("test"). The $ is still omitted and the backslash is displayed.
How can I get the $ to work in a lstlisting?

$s correctly for me. I agree with Herbert that is is most likely a font issue. – Martin Scharrer May 17 '11 at 15:02\usepackage[T1]{fontenc}to the beginning of my preamble... – Seamus May 17 '11 at 16:23