I am trying this code to reverse the even text in ul text :

```
$(document).ready(function () {

    $.fn.reverseText = function () {
        var x = "";
        var x = this.text();
        var y = "";
        for (var i = x.length - 1; i >= 0; i--) {
            y += x.charAt(i);
        }
        this.text(y);
    };
    $("ul li:even").reverseText();
});

```

and the html code is :

```
<ul>
    <li>this text0</li>
    <li>this text1</li>
    <li>this text2</li>
    <li>this text3</li>
</ul>

```

but the output is showing the text0 and text2 both reversed together
like this : 

* 2txet siht0txet siht
* this text1
* 2txet siht0txet siht
* this text3

I have tried to write it like this :

```
$.fn.reverseText = function () {
    this.each(function () {
        var x = "";

        var x = this.text();

        var y = "";
        for (var i = x.length - 1; i >= 0; i--) {

            y += x.charAt(i);
        }

        this.text(y);

    });
};

```

but it gives an error that this.text() is not a function neither the $(this).text() works 

how can I fix this ?