Wednesday, July 29, 2009

Getting a value from JQuery .each()

I struggled mightily trying to get an attribute out of what gets returned from the JQuery .each() function, but eventually tried this and it works:

 <td id="skill_0_ranks" skill_id="0" align="right">0a</td>  
// update skill mods
$('td[skill_id]').each(function(i, element){
skill_id = $(element).attr('skill_id')
update_skill(skill_id)
})


Incidentally, found a cool site for code formatting: http://codeformatter.blogspot.com/2009/06/about-code-formatter.html

No comments: