SHARE
TWEET

Untitled

a guest Jan 21st, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var avatar_layers = new Array('background', 'body', 'hair', 'shirt', 'arms', 'legs', 'feet', 'weapon')
  2.    
  3. ​var array = [];
  4.  
  5. (function(){
  6.     var elements = document.getElementsByTagName("h3");
  7.     for (var i = 0; i < elements.length; i++) {
  8.         array.push(elements[i].innerText);
  9.     }
  10. })();
  11.  
  12. ​alert(array);​
  13.    
  14. $(function(){
  15.     var array = [];
  16.  
  17.     $("h3.title").each(function() {
  18.         array.push(this.innerText);
  19.     });
  20.  
  21.     alert(array);
  22. }​;​
  23.    
  24. var titles = document.querySelectorAll('.title'),
  25.     avatar_layers = [];
  26. for( var i=0; i<titles.length; i++ ) {
  27.     avatar_layers.push( titles[i].innerHTML );
  28. }
  29.    
  30. var avatar_layers = $('.title').map(function(){
  31.     return $(this).html();
  32. });
  33.    
  34. var headingEls = document.querySelectorAll("h3.title");
  35. var avatar_layers = []; // empty array literal
  36. for (var i=0; i<headingEls.length; i++)
  37.     avatar_layers.push(headingEls[i].textContent);
  38.    
  39. <h3 class = 'title'>trtr</h3>
  40. <h3 class = 'title'>tcrtr</h3>
  41. <h3 class = 'title'>tdrtr</h3>
  42. <h3 class = 'title'>trrtr</h3>
  43. <h3>trgtr</h3>
  44.  
  45. var arrayDemo  = [];
  46. $.each($('h3[class*=title]'), function () {
  47.          arrayDemo.push(this.innerHTML);
  48. });
  49.  
  50. alert(arrayDemo);
  51.    
  52. var h3s = document.getElementsByTagName("h3");
  53.  
  54. var arr = [].map.call(h3s, function(el) {
  55.                               return el.textContent || el.innerText;
  56.                            });
  57.    
  58. var titleArray = new Array();
  59. $('h3.title').each(function(){
  60.     titleArray.push($(this).text());
  61. });
  62.  
  63. alert(titleArray);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top