Make a select with element ul

0

I'm trying to do a select without using the select tag, so I'm using the ul and li tags.

I got the table data in the database using PHP and made a dropdown with jquery .

When I click the button, select an option , it shows me the options, but when I try to select an option, nothing happens, how do I select an option from this menu? >

HTML and PHP:

<div class="dropdown-collapse actions search_category">
<?php if ( osc_count_categories() > 1) { ?>
    <?php osc_goto_first_category(); ?>
    <button class="search-button-index">
        <span> <?php _e('Select a category', OSCLASSWIZARDS_THEME_FOLDER); ?> </span>
        <i class="fa fa-caret-down"></i>
    </button>
    <ul>
        <?php
            $i = 0;
            $code = osc_category_code();
         ?>
        <?php while ( osc_has_categories() ) { ?>
            <li><a id="<?php echo $code; ?>"><?php echo osc_category_name(); ?></a></li>
            <?php $i++; ?>
        <?php } ?>
    </ul>
<?php } ?>
</div>

Javascript:

$(".search_category button").click(function(){
    return $(".search_category ul").slideToggle(400),!1})
    
asked by anonymous 09.11.2015 / 21:07

1 answer

0

Good evening. Try this javascript code here.

$(".search_category li a").click(function(){
  alert($(this).attr('id'));
})
    
09.11.2015 / 21:38