Advertisement
ikai2

append title below the swatch

Sep 11th, 2022 (edited)
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // CSS
  2.  
  3. .pf-option-swatches div {
  4.     flex-direction: column;
  5. }
  6.  
  7. // JS
  8.  
  9. const pfSwatches = document.querySelectorAll('.pf-option-swatches > div');
  10.     pfSwatches.forEach(option => {
  11.        const input = option.querySelector('input');
  12.       let spanTitle = document.createElement("span");
  13.       spanTitle.className = "span-title";
  14.       spanTitle.innerText = `${input.value}`;
  15.       option.appendChild(spanTitle);
  16.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement