douji6940 2013-08-27 12:14
浏览 13
已采纳

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!

  • 写回答

1条回答 默认 最新

  • duanjuhuo8772 2013-08-27 12:17
    关注

    Try this

    function logged_in() {
       return $('#userStatus').val() == 'User' ? true : false;
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?