Url Blocking SMF Mod(我的)JQuery:.val()不能正常工作

Well, I have this code:

//Url-Block

echo '<script type="text/javascript">
function logged_in() {
  return $(\'#userStatus\').val() == \'User\' ? true : false;
}
$(document).ready(function() {
  if(!logged_in()) {
    $("#url-lock").html("<span style="color:red;font-weight:bold;">[Sólo los usuarios pueden ver este contenido. <a href="' . $scripturl . '?action=register">Regístrate</a> o <a href="' . $scripturl . '?action=login">loguéate</a> para ver dicho contenido.]</span>").removeAttr("href").wrap("<strong></strong>");
  }
});
</script>';

That makes that the guests can't see any link that have [url-lock] bbc tag... But idk why it doesn't work...

#url-lock works well...
#userStatus too...

So.. Jquery is bad coded, that can I do? I have never programmed in Jquery ;(

The error is here:

    function logged_in() {
  return $(\'#userStatus\').val() == \'User\' ? true : false;
}

Idk, how to do that it works... :/

Sorry, and thank you!

Try this

function logged_in() {
   return $('#userStatus').val() == 'User' ? true : false;
 }