Reputation: 2866
I have a bunch of DIVs identified by class screen-cat-comment and I want for each div to execute a plugin that receives as a parameter an attribute value from each DIV.
<div class="screen-cat-comment" catId="1"></div>
<div class="screen-cat-comment" catId="2"></div>
<div class="screen-cat-comment" catId="3"></div>
then, the selector
$('.screen-cat-comment').fragment({ code: $(this).attr('catId') });
Passing catId to myPlugin doesn't work -- from the current code, $(this).attr('catId') returns undefined. Is there any way to re-write this selector to pass attr('catId') to the plugin?
Upvotes: 0
Views: 34
Reputation: 150263
this
in that context is probably the window
...
$('.screen-cat-comment').each(function(){
$(this).fragment({ code: $(this).attr('catId') });
});
Upvotes: 1