jeudi 25 février 2016

How to use jquery to get classes starting with a value and adding events to chekcboxes in each of the classes

I have a set of classes all beginning with marg-. Something like the pattern below:

'<div class="marg-1 row-">'+
                '<p class="subject-math col-6">Mathematics</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="math-check"  /></div>'+
           '</div>'+
           '<div class="marg-2 row-">'+
                '<p class="subject-eng col-6">English</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="eng-check"  /></div>'+
           '</div>'+
           '<div class="marg-3 row-">'+
                '<p class="subject-phy col-6">Physics</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="phy-check"  /></div>'+
           '</div>'  

I want to write jquery code that will locate them all and add an onselect event to the checkboxes in them.

How do I do this?




Aucun commentaire:

Enregistrer un commentaire