2013-04-08 5 views
1

저는 기본 채팅 스크립트를 작성하고 다음 코드로 약간의 hickup을 사용하고 있습니다. 기본적으로 페이스 북이하는 것처럼 페이지 제목을 "플래시"로 만들려고합니다. jQuery 제목 깜박임

<script> 
    $(function(){ 
     var title = $("title"); 

     var flash = setInterval(function(){ 
      $("#chatbox_2").toggleClass('notify'); 
      (title.text == 'blah') ? title.text("New message...") : title.text('blah'); 
     }, 900); 
    }); 
</script> 

나는 그것을 반환 console.log(title.text()); 경우 blah

사람이 내가 잘못 뭘하는지 볼 수 있을까요?

답변

3

변경 title.text == 'blah'

+0

나는 그렇게 간단한 것을 알고 있었다. 감사. – Menztrual

1

title.text() == 'blah'에 당신은 삼항의 조건에서 .text 당신의 호출 뒤에 괄호를 놓치고있어.

-1

문서 제목을 변경하는 올바른 방법을 염두에두고 document.title = "New title";

이며, 적절한 자바 스크립트는 다음과 같습니다

(function() { 
    var toggle = false, 
     chatbox = document.getElementById('chatbox_2'), 
     flash = window.setInterval(function() { 
      toggle = !toggle; 
      chatbox.className = chatbox.className.replace(/(?:\bnotify\b\s?)?/,toggle ? 'notify ' : ''); 
      document.title = toggle ? "New message..." : "blah"; 
     },900); 
})();