Users Pricing

forum

home / developersection / forums / why am i not able to append an image only if certain classes exist?

Why am I not able to append an image only if certain classes exist?

Jayden Bell 2301 09 Apr 2013
Hi Everyone!

I am trying to use jQuery to append an image tag to a div only if one of three classes exists, but it doesn't seem to be working. It either appends to all 

of the elements or none at all.

Here is the HTML code:

<figure class="donut minus">
    <div class="figure-value"></div>
</figure>
Here is the jQuery:

if ($("figure.donut").hasClass("minus") || $("figure.donut").hasClass("plus") || $("figure.donut").hasClass("plus-minus")) {
        $(".figure-value").append('<img src="../images/schoolProfile/donut-plus-minus.png" />');
    }

Thanks in advance

Jayden Bell

Other


1 Answers