Jquery event click after attribute change

Asked

Viewed 89 times

0

I have a little problem here with Jquery, when the button is clicked I need to take the value of the input and replace the attribute 'href' of one and at the same time click on it... I’m not having results, I can do even the part of replacing the value of the attribute, but I can’t do the click event right after!

btnContacts = boot

contactParams = input text

sendContact = Tag A

Note: this is not a FORM!

$(document).ready( function () {
            $('#btnContatos').click( function () {
                var contato = $('#contatoParams').val()
                //alert(contato)
                $('#enviaContato').attr('href', '/chat/busca/'+contato);

                // Mexer...
            })
        }
  • I think you should use Location.href='/chat/search/'+contact; But by solving your question, adding Rigger doesn’t work? $('#sendContact'). Trigger('click');

  • Using Location worked, easier solution than expected... now comes the thick, configure the controllers and models... Thanks friend!

  • 2

    No need to add "solved" to the question title. You can add your own answer or delete the question.

  • Or accept someone’s answer.

1 answer

3


Using JS to call the new page:

$(document).ready(function(){
    $('#btnContatos').click(function(){
        var contato = $('#contatoParams').val();
        location.href = '/chat/busca/' + contato;
    });
});

Browser other questions tagged

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