Question and answer is powered by AnsPress.io
I get this error jQuery(…).find(…)[i].addClass is not a function
when I using this code:
<script type="text/javascript"> if(res.length>0) { jQuery('.text_order_get').val(res[0].comment); for(var i=0; i<res[0].rating; i++){ jQuery('#stars').find('.star')[i].addClass('selected'); } } </script>
Follow this code, I hope it wil be helpful for you.
Example code is here:
<script type="text/javascript"> jQuery('#stars .star').each(function(i){ if(i<res[0].rating){ $(this).addClass('selected'); } }); </script>