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

105
Views
No hay efecto de enfoque cuando se usa ajax para incrustar html en la página actual y establecer el enfoque

Estoy desarrollando asp.net core y pruebo en el navegador Edge (versión: 96.0.1054.62).

Envío una solicitud ajax y obtengo el contenido html, luego incrusté el bloque html en la página actual. Después de eso, configuré el foco en el elemento html en el bloque html. Pero no puedo ver el efecto de enfoque cuando llamo a la función setFcous .

En general, cuando configuro el foco en un elemento, tendrá un borde negro que lo envuelve como el siguiente.

ingrese la descripción de la imagen aquí

El siguiente es el ejemplo de código:

Índice.cshtml

 <form> <input id="btnDelete" value="Delete" type="button" style="width: 60px" /> </form> <div id="divInputs" style="display: none"> </div> <script type="text/javascript"> function setFocus(elementId) { var obj = document.getElementById(elementId); if (isDefine(obj)) { console.log(obj); obj.focus(); } } function isDefine(obj) { return !(obj == undefined || obj == null) } $(function () { $('#btnDelete').on('click', function () { $.get('/Home/Delete?', (data) => { $('#divInputs').html($(data)); $('#divInputs').show(); setFocus('btnAction'); }); }); }); </script>

HomeController.cs

 public IActionResult Delete() { return View("Delete"); }

Eliminar.cshtml

 @{ Layout = null; } <div> <input id="btnAction" class="button" type="button" value="Delete"/> <input id="btnCancel" class="button" value="Cancel" type="button"/> </div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El foco se establece en el botón de su código. Puede probarlo agregando el siguiente estilo a su página.

 <style> input:focus { background-color: yellow; } </style>
about 4 years ago · Juan Pablo Isaza Report
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!