简体   繁体   English

我不理解$(“。element”)。typed()表示法

[英]I don't understand the $(“.element”).typed() notation

In the code below, I don't understand how the notation: $(".element").typed() works. 在下面的代码中,我不明白这种记法的用法:$(“。element”)。typed()起作用。 I understand that $(".element") refers to the id of a <div> element. 我知道$(“。element”)是指<div>元素的ID。 However, appending .typed() to it seems to assume that typed() is a method of the class <div>. 但是,将.typed()附加到它之后似乎假定typed()是类<div>的方法。 I don't see how that can be. 我不知道怎么回事。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="/typed.js" type="text/javascript"></script> 

<script>
$(function(){
    $(".element").typed({
        strings: ["First sentence.", "Second sentence."],
        typeSpeed: 0
    });
});
</script>

#1 #1

$(".element") refers to the id of a element $(“。element”)表示元素的ID

actually a dot refers to a dom element class. 实际上,点是指dom元素类。 for IDs it's # . 对于ID,它是#

#2 #2

jQuery brought you the jquery objects for dom elements he found with that class and tries to implement on them the function typed() - which isn't a jquery function maybe you mean type() . jQuery为您带来了他在该类中找到的dom元素的jquery对象,并尝试在其上实现typed()函数-这不是jquery函数,也许您是指type() you probably have a typo or using an external plugin for jquery. 您可能有错字或使用外部插件进行jquery。 update it was pointed out to me that typed is indeed a plugin which i did not see was imported. 更新给我指出, typed的确实是一个插件,我没有看到它被导入。 tnx TNX

read more on jquery and how you use it. 阅读更多有关jquery及其用法的信息。 what it gives you back and how can you manipulate data received. 它能给您带来什么回报,以及如何处理收到的数据。

https://jquery.com/ https://jquery.com/

It would appear that typed.js is an extension of jquery. 看来typed.js是jquery的扩展。 This link provides an excellent discussion on the topic. 该链接提供了关于该主题的精彩讨论。

https://learn.jquery.com/plugins/basic-plugin-creation/ https://learn.jquery.com/plugins/basic-plugin-creation/

Thanks one and all! 谢谢大家!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM