let skill_names = ["HTML", "CSS", "JavaScript", "Jquery", "MySQL"]
let skill_number = [10, 20, 30, 40, 50]
for (let i = 0; i < skill_names.length; i ) {
let insert_skill = ` <div >
<div >
<div >
<div ></div>
</div>
</div>
</div>`
$(".skill_info_box").append(insert_skill);
}
for (let i = 0; i < skill_names.length; i ) {
increase_number(i)
}
function increase_number(i) {
let counter = 0;
setInterval(() => {
if (counter == skill_number[i]) {
clearInterval();
}
else {
counter = 1;
**$(".skill_number").eq(i).HTML() = counter "%"**
}
}, 30)
}
i want to insert each number on Array[skill_number] to each class"skill_number" i was expecting to use .eq() or .index() but neither works on what i expect.
CodePudding user response:
Your first stop should always be the documentation. This is wrong in two ways:
$(".skill_number").eq(i).HTML() = counter "%"
- The function is called
html
, notHTML
. - You can't assign a value to the return value of a function. To set the HTML of an element in jQuery, pass the value to the function.
For example:
$(".skill_number").eq(i).html(counter "%");