Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda