在具有特定类的所有元素上触发iScroll 4 [英] Trigger iScroll 4 on all elements with a certain Class
本文介绍了在具有特定类的所有元素上触发iScroll 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以这种方式触发脚本iScroll4
The script iScroll4 is triggered in this manner
$(document).ready(function() {
var myScroll;
myScroll = new iScroll('wrapper');
});
但是,假设存在一个ID为'wrapper'的元素.我想在类名称为"scrollable"的所有元素上触发此操作.我已经在此脚本的插件上看到了此操作.有什么想法在这里怎么做吗?
That however assumes there is an element with ID 'wrapper'. I would like to trigger this on all elements with the class name "scrollable". I have seen this done on a plugin for this script. Any ideas how to do it here?
推荐答案
您可以为同一类"scrollable"分配不同的ID,并...
You can assign a different ID with the same class "scrollable" and ...
$(document).ready(function() {
//Created an array for adding n iScroll objects
var myScroll = new Array();
$('.scrollable').each(function(){
id = $(this).attr('id');
myScroll.push(new iScroll(id));
});
});
这篇关于在具有特定类的所有元素上触发iScroll 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文