Question: Well, it seems strange that no one has asked this question before and it has been bothering me for hours but here's what I am trying to do.

I need to reverse the order of a text file, show the last 10 entries and print the contents but not from the last entry showing first. Rather I wish to maintain the order. ie. the first entry should show first and the last entry should show last.

I already have the PHP code to reverse and show the last 10 entries which I posted below with the help of a user. Thanks a ton for your help in advance!

Code 

```
<?php $text = file('user.txt');
$text= array_reverse($text);
$counter=0; 
while ($counter < 10) { 
   if (isset($text[$counter])) { 
       echo $text[$counter] . "";
   } 
   $counter++;
} 
?>

```

Answer: 
You have three problems.

---

First:

You have configured JS Fiddle to wrap all your code in an onload handler. This stops the function being a global so when you call `addFunc` it can't be found.

---

Second:

You are calling jQuery but haven't included the jQuery library.

---

Third:

The value of `this` depends on how you call the function.

When the `onclick` function is called, `this` is the element.

When `addFunc` is called (if you fix the other problems), since you haven't specified a context, `this` is `window` (the default object).

---

Don't use intrinsic event attributes. Bind your event handlers with JavaScript.

```
jQuery(".add-link").on('click', addFunc);

```

And if you use jQuery, then [include the library](http://jquery.com/download/) in your page.
try to call it with class name :

```
$('.add-link').click(function() {
    var username = $(this).attr('title');
    alert(username);
    $('#content').html(username);
});

```