I want to see if an <li>
has a certain class, the catch is though that they all are unique but all contain a constant string of 'unqID'. I want to check to see if the <li>
has a class that contains this string and if it does not, add the new class to the <li>
. I know how to find out if an element has an exact class name but do not know how to find partial class names.
<li class=orange blue>
<div class=answer>Some Content</div>
</li>
<input type=button name=yellow value=yellow class=yellow />
<input type=text value= class=result />
$(input.yellow).click(function() {
// CREATE UNIQUE CLASS ID
var d = new Date();
var n = d.getTime();
var unq = unqID + n;
//CHECK TO SEE IF LI ALREADY HAS THE UNIQUE CLASS
if ($(div.answer).parent().hasClass(unqID)){
$(input.result).val(has class);
} else {
$(div.answer).parent().addClass(unq);
$(input.result).val(class added);
};
});