如何在jQuery中获取引导选择下拉值?

时间:2019-04-24 10:33:23

标签: php jquery codeigniter bootstrap-select

我在name="country1"下拉菜单中通过查询获取动态数据。现在,我想在警报框中获取的值,但现在无法正常工作。那么,我该怎么做?请帮助我。

代码:

<div class="btn-group bootstrap-select show-tick">
    <div class="dropdown-menu open">
        <div class="bs-actionsbox">
            <div class="btn-group btn-group-sm btn-block">
                <button type="button" class="actions-btn bs-select-all btn btn-default">Select All</button>
                <button type="button" class="actions-btn bs-deselect-all btn btn-default">Deselect All</button>
            </div>
        </div>
        <ul class="dropdown-menu inner state1" role="menu">
            <?php
                $this->db->select('*');
                $this->db->from('states');
                $this->db->where('country_id','101');
                $sql = $this->db->get();
                $result = $sql->result_array();
                foreach($result as $row)
                {
            ?>
                    <li data-original-index="0">
                        <a tabindex="0" data-tokens="null">
                            <span class="text"><?php echo $row['name']; ?></span><span class="glyphicon glyphicon-ok check-mark"></span>
                        </a>
                    </li>
            <?php
                }
            ?>
        </ul>
    </div>
    <select name="country1" class="bootstrap-select" title="India:State" multiple="" data-actions-box="true" tabindex="-98">
        <?php
            $this->db->select('*');
            $this->db->from('states');
            $this->db->where('country_id','101');
            $sql1 = $this->db->get();
            $result1 = $sql1->result_array();
            foreach($result1 as $row1)
            {
                echo "<option value='".$row1['id']."'>".$row1['name']."</option>";
            }
        ?>
    </select>
</div>

jquery代码:

<script>
    $(document).ready(function(){
        $('.state1 li').click(function(){
            state = $(this).text();
            alert(state);
        });
    });
</script>

0 个答案:

没有答案