[英]stellar js initialise with jquery only
stellar js requires following data attribute to element like: 恒星js需要以下数据属性的元素:
<div data-stellar-ratio="2"></div>
However I cannot use inline html on this particular site so I'd need to use only jquery. 但是,我不能在此特定网站上使用内联html,因此我只需要使用jquery。
I tried to add data attribute with jquery but it does not seem to work. 我试图用jquery添加数据属性,但它似乎不起作用。 Anyone have idea why?
有人知道为什么吗?
$(window).stellar();
$('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2');
You need to order your stellar() method : 您需要订购stellar()方法:
$('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2');
$(window).stellar(); //after data-attribute is set...
h!
$('.gallery.home .kuva:nth-child(2)').attr('data-stellar-ratio', '2');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.