i'm new using Jquery.
i'm trying get Objects that are part of a form when i press a button.
my problem is that i have multiples forms with the same class "formulario"
and when i press the button Jquery give me all forms that has the same type class
and i just want the forms where the button was pressed. i have something like this
<div class ="card">
<div class = "card-header">
First Form
</div>
<div class= "card-body">
<form class="formulario">
<label>Input one</label>
<input type text= "text"></input>
<label>Input Two</label>
<input type text= "text"></input>
<form/>
<button class= "btn">Press</button>
<div/>
</div>
<div class ="card">
<div class = "card-header">
Second Form
</div>
<div class= "card-body">
<form class="formulario">
<label>Input one</label>
<input type text= "text"></input>
<label>Input Two</label>
<input type text= "text"></input>
<form/>
<button class= "btn">Press</button>
<div/>
</div>
i'm have tried using Jquery with something like this:
$('.btn').on("click", function () {
$(this).parents().find('.formulario');
});
it give me all the forms that have the class "formulario" but i just want the form where the button was pressed. in other words i just want to look for the parents where the button is, i don't want to look in all html document.
Aucun commentaire:
Enregistrer un commentaire