Reputation: 676
I have the following code part which my friend coded for a project and it uses jQuery library. I have no idea how to put this in Javascript so I can remove jQuery from the project.
function generateButtonClicked() {
disableGenerateButton();
var t = $(".speed").toArray(),
e = $(".status").toArray();
t.reverse(), e.reverse(), doNextBox(t, e)
}
function tripConnecting(t, e, n, a, c, l) {
$(c).html("Connecting"), tripDestination(n, function () {
tripMeasurement(t, e, n, a, c, l)
})
}
I used an online tool to convert this and it gave me the following code but it is not working properly. Any help would be greatly appreciated.
functiongenerateButtonClicked() {
disableGenerateButton().vart = (".speed").toArray(), e = (".status").toArray().t.reverse(), e.reverse(), doNextBox(t, e)
}
functiontripConnecting(t, e, n, a, c, l) {
(c).html("Connecting"), tripDestination(n, function () {
tripMeasurement(t, e, n, a, c, l)
})
}
Upvotes: 1
Views: 64
Reputation: 6587
Try this:
function generateButtonClicked() {
disableGenerateButton();
var t = Array.from(document.getElementsByClassName("speed")),
e = Array.from(document.getElementsByClassName("status"));
t.reverse(); // You could also add `.reverse` to the above declarations.
e.reverse();
doNextBox(t, e);
}
function tripConnecting(t, e, n, a, c, l) {
c.innerHTML = "Connecting";
tripDestination(n, function () {
tripMeasurement(t, e, n, a, c, l);
});
}
Upvotes: 3
Reputation: 674
Method toArray from jQuery looks like:
const elements = Array.from(document.querySelectorAll('.speed'))
Upvotes: 2