function HrefStripper() { this.StripHref = function(parentclass, classname) { $('.' + parentclass).find('.' + classname).find('a').each( function () { //this strips the href tag //$(this).removeAttr('href'); // this turns it into plain text $(this).before($(this).html()).remove(); } ); } } $(document).ready(function() {var stripper = new HrefStripper(); stripper.StripHref('grid', 'nolink'); });