If and else if

If and else if

Hi everyone!
I just started with jquery and now got stuck with if and else if.
What I want to do is:
on click check If defined class1 exists, insert a <p></p> else if defined class2 exists, insert a different <p></p>. And this should check if one of 4 classes exists.
Was this understandable?

This is my current javascript:
$(document).ready(function(){
        $(".a1").click(function() {

        if ( $(".b1") ) {
        $('.b1').append('<p>B1 is there</p>')};
        else if  ($(".b2") ) {
        $('.b2').append('<p>B2 is there</p>');
        alert("b2");}
       
        else if  ($(".b3") ) {
        $('.b3').append('<p>B3 is there</p>');
        alert("b3.");}
       
        else if  ($(".b4") ) {
        $('.b4').append('<p>B4 is there</p>');
        alert("b4.");}
});
});

and the html:

<?php if ($size==4) {echo "<div class='b1'></div>";} elseif ($size==6) {echo "<div class='b2'></div>";}  elseif ($size==10) {echo "<div class='b3'></div>";}  elseif ($size==15) {echo "<div class='b4'></div>";} ?>
</div>
<div id="nav">
<p>Praline auswahlen</p>
<ul>

<li class="a1">item1</li>
<li class="a2">item2</li>
<li class="a3">item3</li>
<li class="a4">item4</li>
</ul>

Does anyone have a clue where my mistake is?
Help is very much appreciated.