1
I’m starting to venture now into the world of development and hit a question while 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 improve the code and to re-show all the courses, everything 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>
What do you want to check on
if
? theif
must have a condition to check within parentheses:if (algo a verificar){ // fazer algo
– Sergio