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

198
Visualizações
Cómo escribir Mostrar más y mostrar menos en JavaScript

Tengo un código cshtml como este

 <span class="p1"> Breaking India: Western Interventions in Dravidian and Dalit Faultlines is a book written by Rajiv Malhotra and Aravindan Neelakandan which argues that India's integrity is being undermined <button class="More">..Show More</button> </span>

Cuando se presiona el botón dentro del lapso, mostrará todos los caracteres. Si lo pulsamos de nuevo, aparecerán 100 caracteres. ¿Cómo puedo hacerlo?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Puede usar un detector de eventos y establecer el padre en el texto completo de esa manera cuando hace clic en el botón

 const fullText = 'Breaking India: Western Interventions in Dravidian and Dalit Faultlines is a book written by Rajiv Malhotra and Aravindan Neelakandan which argues that India\'s integrity is being undermined and some more' // get the more buttons const buttons = document.getElementsByClassName('More'); // attach an click event listener Object.values(buttons).forEach(button => { button.addEventListener('click', (event) => { // onclick set the parents content to the fullText event.target.parentNode.textContent = fullText }) })
 <span class="p1"> Breaking India: Western Interventions in Dravidian and Dalit Faultlines is a book written by Rajiv Malhotra and Aravindan Neelakandan which argues that India's integrity is being undermined <button class="More">..Show More</button> </span>

about 4 years ago · Santiago Trujillo Relatório
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