I have a snippet of JQuery that is being saved into a variable name that helps create a notice on the page. I am trying to change the class associated with the html element if the class has already been added to the page. This is being done in a WordPress plugin.
Below is the original and below that is my first stab at it.
noticeItemOuter = jQuery('<div></div>').addClass('notice-item-wrapper');
My try:
noticeItemOuter = if (JQuery(".notice-item-wrapper").length > 0) {
jQuery('<div></div>').addClass('notice-item-wrapper2');
}else{
jQuery('<div></div>').addClass('notice-item-wrapper');
}
I added console logs inside the if else statement and never saw them pop up.
Aucun commentaire:
Enregistrer un commentaire