Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. /*przyklad 1 */
  2.  
  3.  
  4. var box1 = document.querySelectorAll('.sample_class');
  5. console.log(box1);
  6. function getTag(elements) {
  7. var arr = [];
  8. for (var i=0; i<elements.length; i++) {
  9. arr.push(elements[i].tagName);
  10. }
  11. return arr;
  12. }
  13. console.log(getTag(box1));
  14.  
  15.  
  16. /*przyklad 2 */
  17.  
  18. var box2 = document.querySelector('#sample_id');
  19. console.log(box2);
  20. function getClass(element) {
  21. var arr=[];
  22. for(var i=0;i<element.classList.length;i++){
  23. arr.push(element.classList[i]);
  24. }
  25.  
  26. return arr;
  27.  
  28. }
  29. console.log(getClass(box2));
  30.  
  31.  
  32.  
  33.  
  34. /*przyklad 3 */
  35.  
  36. var box3 = document.querySelectorAll('.sample_class_2 li');
  37. console.log(box3);
  38. function getInnerText(element) {
  39. var arr = [];
  40. for (var i=0;i< element.innerText.length; i++) {
  41. arr.push(element.innerText[i]);
  42. }
  43.  
  44. return arr;
  45.  
  46. }
  47. console.log(getInnerText(box3));
  48.  
  49.  
  50.  
  51.  
  52. /* przyklad 4*/
  53.  
  54. var box4 = document.querySelectorAll('[href]');
  55. console.log(box3);
  56. function getAdress(elements) {
  57. var arr = [];
  58. for (var i=0; i<elements.length; i++) {
  59. arr.push(elements[i].innerText);
  60. }
  61.  
  62. return arr;
  63. }
  64. console.log(getAdress(box4));
  65.  
  66.  
  67. /*przyklad 5*/
  68.  
  69. var box5 = document.querySelector('.sample_class_3');
  70. console.log(box5);
  71. var children=parent.children;
  72.  
  73. getTag(children);
  74. console.log(getTag(children));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement