How to avoid conflicts in Jquery?

Asked

Viewed 48 times

0

I have a system where the user registration is done through stages:

inserir a descrição da imagem aqui

But when the user enters the name, I want that, as happens here on the site, the name automatically appears in a div next to the form. That’s why I did it this way:

<script>
  var nome = document.querySelector('#nome');
  var paragrafoNome = document.querySelector('#paragrafonome');
  nome.addEventListener('keyup', function () {
  paragrafoNome.innerHTML = "<div align='left' style='padding: 10px'><strong>Nome:</strong> <br>" + nome.value + "</div>";
  });
  </script>

<input id="nome" name="nome" type="text" class="md-form-control required">

<p id="paragrafonome"></p>

Only I realized that this code is conflicting with the jquery of the steps, because when I remove this line:

<script src="assets/plugins/forms-wizard-validation/js/jquery.steps.js"></script>

It works normally, but when I leave this line, the auto-fill stops working. I tried to put the $.noConflict(); before the script, but it disabled the steps.

How can I fix this?

  • Hello Sam. Right. I confess that I do not know much Jquery. How could I solve this?

  • 1

    You may be conflicting with the id

  • Right. I made the adjustments and changed my post with the adjustments made, but unfortunately it doesn’t work. I checked for conflicts with the id, but from what I saw, there’s no other id with the same name.

  • combined......

  • 1

    Exchange the keyupfor input to see.

  • 1

    If it doesn’t work, include the code within this function: document.addEventListener("DOMContentLoaded", function(){ COLOQUE O CÓDIGO AQUI });

  • Hello Sam. Unfortunately the conflict continues. I decided to change the shape of the steps and stick with the solution you gave me. Thank you!

  • Only for those who want to apply the idea, I used the step Wizard of this link: https://bootsnipp.com/snippets/j6rkb Worked without conflicts.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.