I want to do a foreach with each in jquery.
My function jquery have a call for another function showTauxPlafonds so i want for every a i have a call for this function to return a result with ajax.
For every <a>
I want when I click I have a call for my function jquery :
$("a").each(function() {
$(this).on("click", function() {
showTauxPlafonds(urlTaux, $(this).attr('tauxPlafonds'));
})
});
var showTauxPlafonds = function(url, tauxPlafonds) {
if (tauxPlafonds != null)
getAjaxedHtmlView(url, {
tauxPlafonds: tauxPlafonds
}, null, 'app_taux_plafonds_values');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="mdc-list-item" tauxPlafonds="PSS" data-toggle="tooltip" data-placement="top" title="Acceuil" style="cursor:pointer;width:350px">
Plafond sécurité sociale
</a>
<a class="mdc-list-item" data-toggle="tooltip" data-placement="top" title="Taux et plafonds" style="cursor:pointer;width:350px">
Smic
</a>