Compare links and highlight them if they are matching

Compare links and highlight them if they are matching

Hi,

I have a table which has two columns (#colA and #colB) , each column contains links, I want to compare the links in #colA to #colB and highlight them in both columns if they are exactly matching links.

So far I have done this but not really working, how can I correct this?

  1. $(document).ready(function() {
  2. $("#colA a").each(function() {
  3. var hreftofind = $(this).attr("href");
  4. $('#colB a[href$="'+hreftofind+'"]').addClass('selected');
  5. });
  6. });