I'm working on some front end funcionalities. Actually I'm doing Ajax requests and modifying the UI after que call.
I identify related items/views to my Model (in front) using an ID which won't be unique because I select the different items by combining class + ID.
Quick Example:
<div id="23"class="status_ic btn btn-info">Status Name</div>
<div class="botones_applies" id="23">
<div class="btn btn-xs btn-primary btn-acept" id="23">
Acept
</div>
<div class="btn btn-xs btn-borrar btn-danger btn-deny" id="23">
Deny
</div>
</div>
I'm doing this:
$('.botones_applies#23').empty();
status_btn = $('.status_ic#23');
status_btn.removeClass('btn-info');
status_btn.addClass('btn-primary');
status_btn.text('Acepted');
I did more views using this kind of selector without any issue but here I'm experiencing the strange behaviour, my first selector is not working while the other one is working and they are using the same logic. I noticed that if I swap the order to $('#23.botones_applies') it works as expected. I can do it because doesn't break anything but I'm concerned about why this happens.
$('.botones_applies#23') ---> doesn't work
$('#23.botones_applies') ---> works
$('.status_ic#23') ---> works
Is there some css or jquery rule that am I missing? Maybe some stupid little thing... Maybe I forget some important concept.. Would someone explain me this? Thank you!
idvalues must be unique in the document, so that's the problem you should solve, after which this problem likely goes away.idvalue must start with letter, not number...#in a CSS ID selector.id="23"s in your markuip (or to ignore previous ones when it sees a new one).