javascript - Drodown list return issue

admin2025-06-02  1

I made a function that doesn't work properly: it correctly returns the slug of the selected tags except the first one in the list. Someone can help me understand why please? The code is below ... Thank you

=============================================

<select>
<option value="" disabled selected>-- choose --</option>
<?php $select = wp_dropdown_categories(array('taxonomy'=>'post_tag', 'value_field' => 'slug', 'show_count'=>1, 'orderby'=>'name', 'echo'=>0)); ?>
<option value="<?php echo $select; ?></option>
</select>

<script type="text/javascript">
$(function () {

$('select').on(‘click’, function() {

var selection = $(this).val();

location.href = '/' + selection;

});

});
</script>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748816651a313965.html

最新回复(0)