Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="https://code.jquery.com/jquery-3.1.0.js"></script><table id="sortable"> 
<tbody> 
<tr> 
<td class="content">A</td>
 </tr>
 <tr> 
<td class="content">B</td> 
</tr>
 <tr> 
<td class="content">A</td>
 </tr> 
<tr> 
<td class="content">C</td> 
</tr> 
<tr> 
<td class="content">C</td> 
</tr> 
</tbody>
 </table>
 
    $(function(){
        var st=document.createElement("style");
        document.head.appendChild(st);
        var sty={}, s;
        var A={}, cou=1;
        $("#sortable .content").each(function(i, c){
             if(!sty[c.innerHTML]){
                sty[c.innerHTML]=1;
                A[c.innerHTML]=cou++;
             }else sty[c.innerHTML]+=1;
             c.setAttribute("data-w", A[c.innerHTML]);
        });
        for(s in sty){
            if(sty[s]>1){
                st.sheet.insertRule("#sortable .content[data-w='"+A[s]+"']{background-color:rgb("+
                    parseInt(Math.random()*256)+","+ 
                    parseInt(Math.random()*256)+","+
                    parseInt(Math.random()*256)+
                ");}", 0);
            };
        };
    });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers