I'm starting to venture into the development world now and hit a question when using IF and Else.
The code below is OK
<select id="course_list" >
<?php $my_query = new WP_Query('tribe_events_cat=petroleo-e-gas'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<option value="course_<?php the_ID(); ?>" >
<?php the_title(); ?>
</option>
<?php endwhile; ?>
</select>
<script type="text/javascript">
$("#course_list").on('change', function(){
$('.course_item').hide();
$('#' + this.value).show();
});
</script>
But when I try to refine the code and show all courses again, everything has stopped working.
<select id="course_list" >
<?php $my_query = new WP_Query('tribe_events_cat=petroleo-e-gas'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<option value="all-posts" >
Mostrar Todos
</option>
<option value="course_<?php the_ID(); ?>" >
<?php the_title(); ?>
</option>
<?php endwhile; ?>
</select>
<script type="text/javascript">
$("#course_list").on('change', function(){
if {
$('.course_item').hide();
$('#' + this.value).show();
}
else
$('.course_item=').show();
});
</script>