J'essayais de parcourir une collection d'objets et essayais de définir un attribut pour chacun des objets.jQuery - comment définir attr pour 'this' ..?
Voici le code:
$(document).ready(function()
{
$('#clickButton').click(function()
{
var hiddenVal = $('#hdnVal').val();
$('*').find('*[tabindex]').each(function(index)
{
//this.setAttribute('tabindex', hiddenVal + this.getAttribute('tabindex'));
$(this).attr('tabindex', 'test');
});
});
});
Je ne pouvais pas définir l'attribut avec $(this).attr('', '');
mais la façon JavaScript fonctionne très bien. Comment puis-je le faire dans jQuery?
@ Tim: un bon travail sur le code prettification :-) –