在我的select元素中添加一个类

I simply want to add class of "btn" to my select element. So the select element will look like

<select class="btn">

Add the class in this code:

<form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get">

        <?php
        $args = array(
            'show_option_none' => __( 'Select category' ),
            'show_count'       => 1,
            'orderby'          => 'name',
            'echo'             => 0,
        );
        ?>

        <?php $select  = wp_dropdown_categories( $args ); ?>
        <?php $replace = "<select$1 onchange='return this.form.submit()'>"; ?>
        <?php $select  = preg_replace( '#<select([^>]*)>#', $replace, $select ); ?>

        <?php echo $select; ?>

        <noscript>
            <input type="submit" value="View" />
        </noscript>

    </form>

The documentation shows an option of 'class' in the args you provide

$args = array(
        'show_option_none' => __( 'Select category' ),
        'show_count'       => 1,
        'orderby'          => 'name',
        'echo'             => 0,
        'class'            => 'btn'
    );

You can also add class using jquery like this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("select").addClass("btn"); }); });