Показать сообщение отдельно
  #5 (permalink)  
Старый 03.01.2016, 00:35
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,068

dinklin,
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<style type="text/css">
#elem{
   color: #006400;
   font-size: 24px;
}

</style>
</head><body>
<div id="elem">old text</div>
<script>
function textChange(change_text) {
 $('#elem').animate({'opacity': 0}, 500, function() {
  $('#elem').html(change_text) ;
  $('#elem').animate({'opacity': 1}, 500, function() {
   i = ++i % arr.length;
   setTimeout(function() {
    textChange(arr[i]) ;
   }, 1000) ;
  }) ;
 }) ;
} ;
var i = 0 ;
var arr = ["new text1", "new text2", "new text3", "new text4"] ;
setTimeout(function() {textChange(arr[i]);}, 1000) ;
</script>
</body>
Ответить с цитированием