Error $x is not defined in chorme console

Error $x is not defined in chorme console

When i use below code

$x("//*[@id='popular-movies']/div[1]/ul/ul[1]/li[1]/a")[0].click()

Its working, But when I use setTimeout function with this code

$(function(){setTimeout(function(){$x("//*[@id='popular-movies']/div[1]/ul/ul[1]/li[1]/a")[0].click()}, 3000); }());

I got error, $x is not defined

Can you help me to solve this?