0

stellar js requires following data attribute to element like:

    <div data-stellar-ratio="2"></div>

However I cannot use inline html on this particular site so I'd need to use only jquery.

I tried to add data attribute with jquery but it does not seem to work. Anyone have idea why?

    $(window).stellar(); 
    $('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2');
niksos
  • 433
  • 1
  • 7
  • 19
  • show your html.... might be problem with the selector otherwise should work....or even may be you should wrap your code within the document.ready function.... – Bhojendra Rauniyar Apr 23 '14 at 09:13

2 Answers2

0

You need to order your stellar() method :

$('.gallery.home .image:nth-child(2)').data('stellar-ratio', '2');
$(window).stellar(); //after data-attribute is set...
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
  • thank you i tried that too but it did not work out :( and yes i have everything inside doc ready – niksos Apr 23 '14 at 12:21
0

doh!

$('.gallery.home .kuva:nth-child(2)').attr('data-stellar-ratio', '2');
niksos
  • 433
  • 1
  • 7
  • 19