convert javascript code to jquery

Asked

Viewed 247 times

-1

How would this code look in javascript:

 var ctx1 = document.getElementById("GraficoDonut1").getContext("2d");
    new Chart(ctx1).Doughnut(data1, options);
    legend(document.getElementById("lineLegend1"), data1);

In jQuery?

  • 4

    Why the interest in doing jQuery? I think succinctly this code.

  • 1

    I already use jQuery in my project, and the code is much simpler and smaller.

  • 3

    If the code in question is the same as it is. jQuery is being used less and less. jQuery is done with Javascript, so the less jQuery the better.

1 answer

1


There’s not much to do in your code, just take the elements by #id via jQuery.

var ctx1 = $("#GraficoDonut1")[0].getContext("2d");
new Chart(ctx1).Doughnut(data1, options);
legend($("#lineLegend1")[0], data1);
  • 3

    But as it was said, there is no need to use jQuery there, the performance of pure Javascript is much higher.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.