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

148
Views
Paragraph element doesn't want to be positioned

Hi I'm working on a drag and drop component website editor. So I added a button when you click it it shown an input element and your input becomes the text of an paragraph element that's pushed to an array everytime you do it My problem is that I want to make it so that when you click with the mouse the mouse x,y position becomes the left,top property of the paragraph element But it sends me an error that says: Cannot read properties of undefined (reading 'left') I already have the code that gets the mouse position so don't worry about it Here's the code

//imports
import {mouse} from '/mouse.js'
//variables
let text_data_holder = document.getElementById('text-field')
let text_data = ''
//Creating text
let text_array = []
text_button.addEventListener('click', function() {
  text_data_holder.style.display = 'block'
})
text_data_holder.addEventListener('change', function(e) {
   e.preventDefault()
   text_data += e.target.value
     for(let i = 0; i < 1; i++){
       text_array[i] = document.createElement('p')
       .innerText = text_data
       text_data_holder.after(text_array[i])
       console.log(text_data)
       text_array[i].left = mouse.x
    }
})
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!