4
I discovered by accident these days ago that in jQuery it is possible to pass a callback function to the function html
.
Behold:
$(function ()
{
$('body').html(function ()
{
return [1, 2, 3, 4, 5];
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
And not only that, but also for the functions css
, prepend
, append
and etc...
Enfin, I would like to know what are the benefits I could draw through this jQuery feature.
$()
selector +propriedade
- That doesn’t explain itself ?– Edilson
Sometimes I ask questions I already know the answer so I can help to have more content on the site @Edilson
– Wallace Maxters