http://jsfiddle.net/borayeris/6kvyb/
<ul>
<li>foo</li>
<li>bar</li>
</ul>
<script>
$('li').each(function(index) {
var qq=$(this).text();
alert(index + ': ' + qq);
});
alert(qq);// Asking this one.
</script>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ve declared qq inside the scope of the function. Once that function exits, qq doesn’t exist anymore.
If you want to have an alert for qq, you need to declare it outside of the function. Keep in mind that it will only contain the last value that was assigned to it.