Header menu

_________________________________________________________________________________

Monday, 2 September 2013

Access html form field using their name in jquery

<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script type="text/javascript" >
        $(document).ready(function(){
            $("#sub").on("click",function(){
                $('input[name="bio[]"]').each(function() {
                    console.log($(this).val());
            });return false;
        });
    });
        </script>
        </head>
    <body>
<form action="#">
First name: <input type="text" name="bio[]"><br>
Last name : <input type="text" name="bio[]"><br>
Phone     : <input type="text" name="bio[]"><br>
Address   : <input type="text" name="bio[]">
<input type="submit" value="submit" id="sub"><br>
</form>
</body>
</html>

No comments:

Post a Comment