jQuery Mobile: A Form Inside A Collapsible Content List

This entry is part 29 of 73 in the series jQuery Mobile

In jQuery Mobile, we can have a form inside a collapsible content list.  This is done by using the fieldset tag with data-role=’collapsible’.

The fieldset is put one level under the form tag.

Inside the collapsible form, there is a text-input field and 3 checkboxes for selection.

<!DOCTYPE html>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
<div data-role='page'>
    <div data-role='header'><h1>Collapsible</h1></div>

        <fieldset data-role='collapsible'>
            <legend>Form Inside A Collapsible</legend>
            <label for='textinput_id'>Text Input:</label>
            <input type='text' name='textinput' id='textinput_id' placeholder='Text input' value=''>

            <div data-role='controlgroup'>
                <input type='checkbox' name='checkbox_n1' id='checkbox_id1'>
                <label for='checkbox_id1'>One</label>
                <input type='checkbox' name='checkbox_n2' id='checkbox_id2'>
                <label for='checkbox_id2'>Two</label>
                <input type='checkbox' name='checkbox_n3' id='checkbox_id3'>
                <label for='checkbox_id3'>Three</label>

    <div data-role='footer' data-position='fixed'>
Try The Code
Series Navigation<< jQuery Mobile: Icons For Collapsible Set
jQuery Mobile: Collapsible Set With Different Icons >>

Leave a comment

Leave a Reply