I have a form with id=”main-form” and inside that there’s a class=”block-footer”
Inside that an element:
<button type="button">Submit</button>
How can I use jQuery to find this button without my adding an Id to the element? The button always has the text of Submit.
Is it worth using the id=”main-form” as a starting point in my selection to make it more efficient?
Select all the
<button>elements, then filter them based on theirinnerHTML:If needed you can be more explicit by only selecting button elements with
type="button", although this is slightly less efficient:As for your comment:
Sure you can.
You could also use
$container.find(), which has the exact same effect.