Показать сообщение отдельно
  #1 (permalink)  
Старый 18.02.2020, 13:33
III III вне форума
Аспирант
Отправить личное сообщение для III Посмотреть профиль Найти все сообщения от III
 
Регистрация: 08.10.2014
Сообщений: 66

При выполнении JS появляются теги HTML
Всем привет. Проблема следующая. При выполнении JS в начале и в конце первой строки появляются символы <, в конце второй строки появляется </, потом они пропадают. Спецы посмотрите в чем причина. Я в этих делах ноль. Скрипт из инета. Всем спасибо.
function autoType(elementClass, typingSpeed){
  var thhis = $(elementClass);
  thhis.css({
    "position": "relative",
    "display": "inline-block"
  });
  thhis.prepend('<div class="cursor" style="right: initial; left:0;"></div>');
  thhis = thhis.find(".text-js");
  var text = thhis.html().split('');
  var amntOfChars = text.length;
  var newString = "";
  thhis.html("|"); 
  setTimeout(function(){
    thhis.css("opacity",1);
    thhis.prev().removeAttr("style");
    thhis.html("");  
    for(var i = 0; i < amntOfChars; i++){
      (function(i,char){
        setTimeout(function() {
          newString += char;
          thhis.html(newString);
        },i*typingSpeed);
      })(i+1,text[i]);
    }
  },1500);
}
  
$(document).ready(function(){
  // Now to start autoTyping just call the autoType function with the 
  // class of outer div
  // The second paramter is the speed between each letter is typed.   
  autoType(".type-js",200);
});


<div class="type-js headline">
    <div class="text-js">
        <h1>
            Привет, Вася!
             <br>
            Как дела?
        </h1>
    </div>
</div>
Вложения:
Тип файла: zip 33.zip (220.8 Кб, 2 просмотров)

Последний раз редактировалось III, 18.02.2020 в 15:17.
Ответить с цитированием