Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Some quick tips;

  1. Look at caching $(this) Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);
Source Link
Matt
  • 181
  • 4

Some quick tips;

  1. Look at caching $(this). You're regularly re-creating a jQuery object that doesn't change.

  2. Adhere to the common JavaScript coding conventions; normally a variable that starts with a capital letter denotes a constructor (that should be invoked with new). Change all your SaturdayFromHValues etc variable names to saturdayFromHValues

  3. As mentioned by @priteaes, you should save the HTML you're constructing to a string and write it to the element once. DOM manipulation is slow, and the browser will be re-paining the window with each append() you're using;

    $(this).append('<div id="label">' + day + ': </div>')
     .append('<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>')
     .append('<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>')
    

Becomes:

 var html = '';
 html += '<div id="label">' + day + ': </div>';
 html += '<select id="' + day + 'FromH" name="' + day + 'FromH" class="hour from"></select>';
 html += '<select id="' + day + 'FromM" name="' + day + 'FromM" class="min from"></select>';
 $(this).append(html);
default

AltStyle によって変換されたページ (->オリジナル) /