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

203
Visualizações
no se puede acceder al hacer clic en la función de un css

tengo un codigo asi

 <form asp-controller="Products" asp-action="AddComment" asp-route-id="@Model.Id" id="CommentForm"> <div class=" w-100 mt-1 ml-5 mr-5 d-block"> <div class="d-inline-block"> <lable class="product-subtitle">Name</lable> <input id="Name" type="text" class="reply-comment" value="@fullname" disabled /> </div> <div class="d-inline-block "> <lable class="product-subtitle">Email</lable> <input id="Email" type="email" class="reply-comment" value="@userEmail" /> </div> </div> <div class="mt-1 ml-5 mr-5 d-block "> <textarea rows="3" class="reply-comment" id="Comment" name="Comment"></textarea> </div> <div class="mt-1 ml-5 mr-5 mb-4 d-flex justify-content-end"> <div> <a class="btn btn-primary btn-buy d-flex justify-content-center add-comment" data-id="0" data-ischild="0" style=" background-color: #425fab;width:80px; padding:10px"><span>Send</span></a> </div> </div> </form>

y js

 $(".add-comment").click(function () { //some thing happens in here });

esto funciona bien y puedo acceder a la función .add-comment.click() , pero en alguna parte tengo que agregar el área de texto por javascript como este

 let divStr = "<div class='w-75 d-inline-flex'><textarea id='ChildComment' class='reply-comment w-100' ></textarea></div>"; divStr = divStr + "<div class='w-25 d-inline-flex align-bottom' style='float:left; justify-content:left;'>"; divStr = divStr + "<a class='btn btn-buy d-inline add-comment' data-id='" + commentId +"' data-ischild='1'><span class='mr-1 ml-1'> Send</span></a></div>"; $("#" + commentId).append(divStr);

pero no puedo ingresar .add-comment.click(function()) cuando hago el área de texto por javascript

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

0

Trata de cambiar

 $(".add-comment").click(function () { //some thing happens in here });

dentro de esto

 $(document).on('click', '.add-comment', function() { //some thing happens in here });

El primero no funciona porque el elemento se agrega después de cargar el DOM.

about 4 years ago · Santiago Trujillo Relatório

0

Esto se debe a que está intentando adjuntar un evento de clic a un elemento que se ha agregado dinámicamente. Prueba esto:

 $(document).on('click','.reply-comment',function(){//do something})
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