How Can I Rewrite This More Efficiently

BRogers

I have to believe that there's a better way to write the below code. Thanks in advance.

var hProtein = $('#protein-lbl');
var hCarb = $('#carb-lbl');
var hFat = $('#fat-lbl');
var hTotal = $('#totalCalories');

// Normal Calc vars
var nProtein = $('#protein-normal-lbl');
var nCarb = $('#carb-normal-lbl');
var nFat = $('#fat-normal-lbl');
var nTotal = $('#totalCalories-normal');

// Hide calculations until bodyweight is entered
hProtein.hide();
hCarb.hide();
hFat.hide();
hTotal.hide();
nProtein.hide();
nCarb.hide();
nFat.hide();
nTotal.hide();
kevinji

Perhaps giving the HTML elements a class will work?

var $ele = $('.class-name');
$ele.hide();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I write this CSS more efficiently?

From Dev

How can I write this CSS more efficiently?

From Dev

How can I rewrite this query to be more readable?

From Dev

How can I use find command more efficiently?

From Dev

How can I more efficiently search a large list in python?

From Dev

How can I use find command more efficiently?

From Dev

How can I more efficiently render Mathjax content?

From Dev

How can I more efficiently arrange my AXML layout?

From Dev

How can I more efficiently perform a query that returns how many times an ID appears in two other tables?

From Dev

How can I more efficiently deal with DBNull.value in vb.net / SQL Server

From Dev

How can I calculate the slope of multiple subsets of a data frame more efficiently?

From Dev

How can I group intra-day time periods into groups of 15 minutes in SAS more efficiently?

From Dev

How can I write my code more efficiently for use with different types of JavaFX GUI components?

From Dev

How can I import csv file to MySQL database more efficiently with PHP?

From Dev

How can I rewrite this a generic?

From Dev

How can I rewrite URLs?

From Dev

Can I split this column containing a mix of tuples/None more efficiently?

From Dev

Any attribute or converter I can use to parse this JSON more efficiently?

From Dev

How can I shuffle bits efficiently?

From Dev

How can I efficiently index a file?

From Dev

How can I efficiently find the accuracy of a classifier

From Dev

How can I efficiently store a grid of rectangles?

From Dev

How can I efficiently merge these two datasets?

From Dev

How can I efficiently render an image in Django?

From Dev

How can I implement these JavaScript functions efficiently

From Dev

How can I efficiently use threads in this case?

From Dev

How do I more efficiently insert footnotes into a Hexo post?

From Dev

How would I write the below code more efficiently?

From Dev

How can I rewrite with apache mod_rewrite an entire directory?

Related Related

  1. 1

    How can I write this CSS more efficiently?

  2. 2

    How can I write this CSS more efficiently?

  3. 3

    How can I rewrite this query to be more readable?

  4. 4

    How can I use find command more efficiently?

  5. 5

    How can I more efficiently search a large list in python?

  6. 6

    How can I use find command more efficiently?

  7. 7

    How can I more efficiently render Mathjax content?

  8. 8

    How can I more efficiently arrange my AXML layout?

  9. 9

    How can I more efficiently perform a query that returns how many times an ID appears in two other tables?

  10. 10

    How can I more efficiently deal with DBNull.value in vb.net / SQL Server

  11. 11

    How can I calculate the slope of multiple subsets of a data frame more efficiently?

  12. 12

    How can I group intra-day time periods into groups of 15 minutes in SAS more efficiently?

  13. 13

    How can I write my code more efficiently for use with different types of JavaFX GUI components?

  14. 14

    How can I import csv file to MySQL database more efficiently with PHP?

  15. 15

    How can I rewrite this a generic?

  16. 16

    How can I rewrite URLs?

  17. 17

    Can I split this column containing a mix of tuples/None more efficiently?

  18. 18

    Any attribute or converter I can use to parse this JSON more efficiently?

  19. 19

    How can I shuffle bits efficiently?

  20. 20

    How can I efficiently index a file?

  21. 21

    How can I efficiently find the accuracy of a classifier

  22. 22

    How can I efficiently store a grid of rectangles?

  23. 23

    How can I efficiently merge these two datasets?

  24. 24

    How can I efficiently render an image in Django?

  25. 25

    How can I implement these JavaScript functions efficiently

  26. 26

    How can I efficiently use threads in this case?

  27. 27

    How do I more efficiently insert footnotes into a Hexo post?

  28. 28

    How would I write the below code more efficiently?

  29. 29

    How can I rewrite with apache mod_rewrite an entire directory?

HotTag

Archive