пустая проверка для этого скрипта? - PullRequest
0 голосов
/ 23 февраля 2011

между head

<head><script type="text/javascript">$(document).ready(function() {
        $.twitter.start({
            searchType:"searchWord", 
            searchObject:"google", 
            lang:"en", 
            live:"live-180", 
            placeHolder:"tweetContainer", 
            loadMSG: "Loading messages...", 
            imgName: "loader.gif", 
            total: 6, 
            readMore: "Read it on Twitter", 
            nameUser:"image", 
            openExternalLinks:"newWindow", 

        });


    });</script></head>

между body

<body>
<div id="tweetContainer"></div>
</body>

Я хочу сделать пустую проверку для контейнера твитов, как будто нет твитов, а затем скрыть Div tweetContainer

1 Ответ

1 голос
/ 23 февраля 2011

Вы можете сделать это

if($("#tweetContainer").eq(0).html() == '')
{
  //this implies there are no tweets. so do whatever you need to
  $("#tweetContainer").hide();
}

Надеюсь, что это поможет!

Если вам нужно делать это регулярно, то, возможно, вы могли бы сделать

function checkTweets()
    {
        if($("#tweetContainer").eq(0).html() == '')
        {
          //this implies there are no tweets. so do whatever you need to
           $("#tweetContainer").hide();
        }
        else
           $("#tweetContainer").show();


    }
    //fire once and then setTime out
    checkTweets();
    setTimeout(checkTweets,100);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...