I have a problem using the .replaceWith()
, it's working for the first blur, but not for the second one, here's my code :
$("#wilaya").blur(function () {
$("#wilayaRow .tdrequired").css("color", "#333");
if ($("#wilaya").val() !== "Selectionnez une wilaya...") {
$("#wilayaRow .tdrequired label").replaceWith("<img src='../../Images/check-mark-md.png' width='20px' height='28px'></img>");
}
else {
$("#wilayaRow .tdrequired label").replaceWith("<img src='../../Images/red-wrong-cross-md.png' width='20px' height='28px'></img>");
}
});
And here's the html part :
<table>
<tr id="wilayaRow">
<td class="tdtitle">
<label for="wilaya">Wilaya d'immatriculation</label>
</td>
<td class="tdinput">
<select name="wilaya" id="wilaya">
<option>Selectionnez une wilaya...</option>
<option>Khalil</option>
<option>Moh</option>
</select>
</td>
<td class="tdrequired">
<label>*</label>
</td>
</tr>
...
</table>
Thanks for your help in advance :)