1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > css带占位符的搜索框 superplaceholder.js-功能强大的超级输入框占位符插件

css带占位符的搜索框 superplaceholder.js-功能强大的超级输入框占位符插件

时间:2021-08-03 23:52:26

相关推荐

css带占位符的搜索框 superplaceholder.js-功能强大的超级输入框占位符插件

superplaceholder.js是一款带演示功能的超级输入框占位符JavaScript插件。superplaceholder.js可以让占位文本动起来,它能够周期性的循环显示预定义的文本字符串,增强提示功能,提升用户体验。

安装

可以通过bower或npm来安装superplaceholder.js插件。

bower install superplaceholder

npm install superplaceholder

使用方法

使用该插件需要在页面中引入superplaceholder.js文件。

初始化插件

使用superplaceholder.js插件的基本语法格式为:

superplaceholder({

el: ,

sentences: ,

options: {} // 可选的自定义参数

});

例如:

superplaceholder({

el: document.querySelector('input'),

sentences: [ '要显示的占位文本', '其它一些文本信息']

});

配置参数

superplaceholder({

el: document.querySelector('input'),

sentences: [ 'Something to show', 'Another thing to show'],

options: {

// delay between letters (in milliseconds)

letterDelay: 100, // milliseconds

// delay between sentences (in milliseconds)

sentenceDelay: 1000,

// should start on input focus. Set false to autostart

startOnFocus: true,

// loop through passed sentences

loop: false,

// Initially shuffle the passed sentences

shuffle: false,

// Show cursor or not. Shows by default

showCursor: true,

// String to show as cursor

cursor: '|'

}

});

letterDelay:各个字符显示之间的延迟时间,单位毫秒。

sentenceDelay:各个句子之间的延迟时间,单位毫秒。

startOnFocus:在输入框聚焦时才开始播放,设置为false会自动开始播放。

loop:是否循环播放。

shuffle:是否打乱传入的句子。

showCursor:是否显示光标,默认为显示。

cursor:光标字符串。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。