jQuery PHP为具有特定值的元素添加新属性

I need to create a function that will add an attribute to elements that have an attribute with specific values.

$index have values 0-10, Code is working to this point: var element = $("a[data-slide-index*='"i"']");

Firebug gives me:

Blockquote SyntaxError: missing ) after argument list

Rest looks like that:

<script type="text/javascript">

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

                for(var i=0; i<parseInt(<?php echo json_encode($index); ?>);i++){

                  var hoverAtt = "onHover"+i+"()";
                   var element = $("a[data-slide-index*='"+ i +"']");


                 element.next().attr("onmouseover", function(){
                       return hoverAtt;

                   });

                   }
           })
            </script>

There is jFidle example for $index=6: http://jsfiddle.net/Fuh9P/

Edit: I changed concatenation as Sjoerd suggested but still doesn't work.

The error message is because you concatenate strings the wrong way. You have this:

var element = $("a[data-slide-index*='"i"']");

Within the $() you try to concatenate three parts, like this:

"a"i"b"

Instead, you should use something like this:

"a" + i + "b"
var element = $("a[data-slide-index*='" + i + "']");