joshlevinson

Untitled

Feb 13th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var els = new Array();
  2. var pleaseselect;
  3. $j("select.wpsc_select_variation option").each(function(index, ele){
  4. if(index == 0){
  5. pleaseselect = ele;
  6. return;
  7. }
  8. var i = $j(ele).text();
  9. i = i.replace("\"", "");
  10. i = i.replace("''", "");
  11. if (i.indexOf("-") >= 0){
  12. i = i.split('-');
  13. split = i[1].split('/');
  14. i = eval(i[0]) + split[0] / split[1];
  15. }
  16. else if(i.indexOf("/") >= 0){
  17. split = i.split('/');
  18. i = split[0] / split[1];
  19. }
  20. i = eval(i);
  21. els[i] = ele;
  22. //note 1
  23. console.log(i + ':' + ele);
  24. });
  25. //note 2
  26. $j.each(els, function(index, el){
  27. console.log(index + ':' + el);
  28. });
  29. //note 3
  30. $j(els).each(function(index, ele){
  31. console.log(index + ':' ele);
  32. });
  33.  
  34. In Chrome, the console.log at note 1 results in:
  35.  
  36. [1: option, 2: option, 0.75: option, 0.375: option,
  37. 0.625: option, 1.5: option, 1.25: option, 1.75: option, 0.5: option]
  38. >
  39. >0.5: option
  40. >0.75: option
  41. >0.375: option
  42. >0.625: option
  43. >1: option
  44. >1.5: option
  45. >1.25: option
  46. >1.75: option
  47. >2: option
  48. length: 3
  49. >__proto__: Array[0]
  50.  
  51. Where the > is a expand/collapse-able arrow that expands/collapses what is below it. Clicking and of the sub >'s expands that full object - with all of the properties you would expect from an option object.
  52.  
  53. However, the length of the array appears to be 3.
  54.  
  55. In Firefox, the log shows this (same behavior as chrome, but with + instead of >)
  56. The two options in the parent correspond with the option at value 1 and 2.
  57.  
  58. +[undefined, option, option]
  59. +0.375 option
  60. +0.5 option
  61. +0.625 option
  62. +0.75 option
  63. +1 option
  64. 1.25 option
  65. 1.5 option
  66. 1.75 option
  67. 2 option
  68.  
  69. Note 1 and note 2 result (respectively) in this:
  70.  
  71. 0:undefined
  72. 1:<option value=​"13">​1"​</option>​
  73. 2:<option value=​"21">​2''​</option>​
  74.  
  75. and this:
  76.  
  77. 0:undefined
  78. 1:[object HTMLOptionElement]
  79. 2:[object HTMLOptionElement]
Advertisement
Add Comment
Please, Sign In to add comment