I followed all the answers on this post jQuery: Adding two attributes via the .attr(); method and none of them work for multiple attributes, only single attribute work.
E.g.
$("img").attr({
data-aos: "fade-down",
data-aos-duration: "600"
});
Does not work. But single attribute does work:
$("img").attr("data-aos", "fade-down");
https://jsfiddle.net/bwj5uex0/3/ You can test on JSFiddle with your browser's built-in dev tools after CTRL+Enter.
-character is being interpreted as the subtraction operator, so you have a syntax error. You instead need to wrap the attribute names in quotes: jsfiddle.net/bwj5uex0/4. Voting to close as a typo$(myObj).attr({"data-test-1": num1, "data-test-2": num2});num1 num2not quoted as answered below in this question.