Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

417
Views
Javascript returns [object HTML Span element]

enter image description heredrag.php

I have array shuffled with shuffled words and when I try to set textContent of box to word it show this

    <script>
      var firstContainer = document.getElementById('pickzone');
    var sentense =<?php echo "'$array'" ?>; //getting string of sentense
    var arrOfWords = sentense.split(" ") // spliting it into array of strings(words)
    var dropZones = document.getElementsByClassName('zone');
    var shuffled = arrOfWords.sort(() => Math.random() - 0.5)// shuffling array of words in random order
    
    for (let i = 0; i < arrOfWords.length; i++) {
        let box = document.createElement('span');
        arrOfWords[i] = box;
        box.setAttribute('class', 'box');
        box.setAttribute('draggable', 'true')
        box.textContent = shuffled[i] // this is the problematic part I guess
        box.addEventListener('dragstart', (event) => { 
            dragBox = event.target;
        })
    
        firstContainer.appendChild(box);
    }
</script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!