0

I am building a website where I have an ADMIN page. There are multiple input fields. Im working with a mongodb database using jade. Here is the code for the users in jade: ul.allUsersList each user, i in userlist li.users label Username:   span.usernameField #{user.username}   label Email:   span #{user.email}   label Points:   span #{user.points}   if user.luniConsecutivi >= 5 label.red Luni consec.:   span.red #{user.luniConsecutivi}   else label Luni consec.:   span #{user.luniConsecutivi}   label Telefon:   span 0#{user.phoneNo}   label Permissions:   span #{user.permissions}   label.reducere Reducere:   span.reducereValue #{user.reducere} RON

There is the .usernameField. What Im trying to do is when the .usernameField is clicked I get that value from the span and add it to all the input fields (for easier use). Here is jQuery code:

`$(document).ready( () => {
    $('.usernameField').on('click', () => {
        let user = $(this).text();
        console.log(user);

        document.getElementById('incField').value = user;
        document.getElementById('decField').value = user;
        document.getElementById('removeField').value = user;
    })
});`

The problem is that in the jQuery code user is always an empty string. How can I get the innerHTML of the li that I click on correctly?

Thank you in advance!

Ballo Adam
  • 105
  • 1
  • 8

0 Answers0