【问题标题】:Link in typed.js texttyped.js 文本中的链接
【发布时间】:2015-01-14 07:57:05
【问题描述】:

如何在typed.js 脚本中添加链接?我需要联系我,以链接到联系页面。

    <script src="js/typed.js"></script>
    <script>
      $(function(){
          $(".element").typed({
            strings: ["Welcome to my Website.", "Random text... Contact me"],
            typeSpeed: 0
          });
      });
    </script>

 **HTML**

<div class="col-md-12 col-xs-12">
    <h1 class="element"></h1>
 </div>

【问题讨论】:

  • 你应该在 之前加载 jQuery 它是插件。
  • 我有它链接这个.. codecode
  • 到底是什么问题?
  • 我需要联系我,做个链接,

标签: javascript hyperlink effect typed


【解决方案1】:

使用回调参数。

示例:

$(function() {
  $('#awesome').typed({
    strings: ["Welcome to my Website.", "Random text... Contact me"],
    typeSpeed: 0,
    callback: function() {
      $('#awesome').html('<a href="#">' + $('#awesome').html() + '</a>')
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://raw.githubusercontent.com/mattboldt/typed.js/master/js/typed.js"></script>

<div class="col-md-12 col-xs-12">
  <h1 class="element" id="awesome"></h1>
</div>

【讨论】:

  • 谢谢 ;) 它正在工作,但现在

    中的所有内容都已链接。
  • @KristjanVričko 请编辑您的问题并提供您的 HTML 代码...这是 CSS 选择器的问题。
  • 我建议你用 id 标识文本占位符
  • @NabilKadimi 我认为您在这里错过了实际问题。通过使用回调函数。 #awesome 中的文本将始终被锚定。但问题是只在typed.js 中锚定Contact me 文本。这个问题问得好。但是很抱歉您给出的答案不符合问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-15
  • 1970-01-01
  • 2013-04-07
  • 2010-09-24
  • 2012-04-08
  • 1970-01-01
相关资源
最近更新 更多