jquery plugin manipulation
<p>I have a jquery plugin that looks like this, </p>

<pre><code>$.fn.customSelect = function() {
  // define defaults and override with options, if available
  // by extending the default settings, we don't modify the argument
 return this.each(function(i) {  
 obj = $(this);  
obj.after("&lt;div class=\"selectoptions_"+i+"\"&gt; &lt;/div&gt;");
obj.find('option').each(function(i){ 
  $(".selectoptions_"+i).append("&lt;div id=\"" + $(this).attr("value") + "\" class=\"selectitems\"&gt;&lt;span&gt;" + $(this).html() + "&lt;/span&gt;&lt;/div&gt;");
});
obj.before("&lt;input type=\"hidden\" value =\"\" name=\"" + this.name + "\" class=\"customselect\"/&gt;&lt;div class=\"iconselect\"&gt;" + this.title + "&lt;/div&gt;&lt;div class=\"iconselectholder\"&gt; &lt;/div&gt;")
.remove();
$('.iconselectholder').hide();
$(".iconselect").click(function(){
$(".iconselectholder").toggle("slow");});
    $(".iconselectholder").append( $(".selectoptions_"+i)[0] );
$(".selectitems").mouseover(function(){
    $(this).addClass("hoverclass");
});
    $(".selectitems").mouseout(function(){
    $(this).removeClass("hoverclass");
    });
    $(".selectitems").click(function(){
    $(".selectedclass").removeClass("selectedclass");
    $(this).addClass("selectedclass");
    var thisselection = $(this).html();
$(".customselect").val(this.id);
    $(".iconselect").html(thisselection);
    $(".iconselectholder").toggle("slow")
    });
    });  
  // do the rest of the plugin, using url and settings
}
</code></pre>

<p>You can see that I have tried to pass <code>i</code> through the function so that it assigns an unique identifier to the class name, however if there multiple instances of this class on the page, they all get the same identifying number, I was hoping that each time it found the class it would an the last unique identifier + 1.</p>

<p>The plugin basically searches for <code>selects</code> and replaces it with <code>divs</code></p>
