Say you have 10-15 fixed divs that you'd like to animate() with different parameters. Using jQuery, what's the best method to pass different parameters for each div? My current method, below, attempts to pass the id text in the function. This is the first step, and eventually I imagine I'd pass the animation() duration and rotation in as function parameters (e.g. float(ID, duration, rotation)It now returns the following: Error: Syntax error, unrecognized expression: "#candy"
$(document).ready(function () {
float("candy");
float("candy2");
//etc
});
function float(ID) {
let id = "#" + ID;
$('"' + id + '"').animate({
top: 100,
}, 5000 );
};
'"' + id + '"'Do only $(id) and you should be fine on the error, side.