jquery find method

Posted by yoda on Stack Overflow See other posts from Stack Overflow or by yoda
Published on 2011-02-24T23:19:23Z Indexed on 2011/02/24 23:25 UTC
Read the original article Hit count: 189

Filed under:
|

Hi,

I have a function called using an anchor inside a form, and I need to get the values of the inputs inside the same form to perform certain actions. Problem is, the result is always undefined.

Here's the code :

$('#create_alert').live('click', function(e) {
    var form = $(this).parent().get(0);

    var id = $(form).find('input[name="id"]').val();

    alert(id);
});

.. and the context :

<form name="create_alert">
<input type="hidden" name="id" value="1" />
<a href="#" type="text" id="create_alert" class="search-submit">CRIAR ALERTA</a>
</form>

Thoughts?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery