April 24, 201511 yr <script> $( document ).ready(function() { $("ul.products > li").addClass(function(i){return "item" ;}); }); </script> This code above adds a class "item" to each of my product li's. I am trying to add: "sbsa-animation="bounceInLeft" sbsa-time="1.5" inside each li tag but not sure how to add it because this is not a class attribute! Edited April 24, 201511 yr by Benn_Kingy
April 24, 201511 yr Hi Benn, You can do this using the attr() method. Also, you don't need to return a function to add a class to multiple items. A simple addClass('item') will do. Here is the full code: $( document ).ready(function() { $("ul.products > li") .addClass("item") .attr({ "sbsa-animation": "bounceInLeft", "sbsa-time": "1.5" }); }); And an example: http://jsfiddle.net/LyndseyB/nnsxq0p7/ Edited April 24, 201511 yr by Lyndsey
Create an account or sign in to comment