Locating nearest section id if it exists
I need to pass the id of the nearest "section" if it exists. If a section doesn't exist, I need to pass the "formPlace" hidden field. If that doesn't exist, I need to pass the URL of the page. How can I do that with jQuery?
- <section id="contactForm">
- <form...
- <input type="hidden" name="formPlace" id="formPlace" value="contact1234">
- ...
- </form>
- </section>