jeudi 23 novembre 2017

Matching a variable with a checkbox label

Hours spent trying to get the correct syntax for this. I want to find the checkbox that has a label matching the variable 'mytext', and then make that checkbox label red. I seem to have tried all combinations of find() and text() but nothing works. Please help. http://ift.tt/2zey41N

<div id="Both_containers">
<div id="Upper_container">
<label><input type="checkbox" value="PP1" />Iron ore</label>
<label><input type="checkbox" value="PP2" />Coal</label>
<label><input type="checkbox" value="PP3" />Flux</label>
</div>
</div>

.

var mytext = "Coal";
$('#Both_containers div label').find(mytext).text().addClass('make_red');

.

.make_red{
 color: red;
}




Aucun commentaire:

Enregistrer un commentaire