Skip to content

Instantly share code, notes, and snippets.

@ccheney
Created October 11, 2012 22:10
Show Gist options
  • Save ccheney/3875832 to your computer and use it in GitHub Desktop.
Save ccheney/3875832 to your computer and use it in GitHub Desktop.
jQuery: if href is blank remove the a tag
$(function(){
$("#buttons a").each(function() {
var href = $(this).attr("href");
if(href == '') {
var imgSRC = $("img", this).attr("src");
var imgSPL = imgSRC.split('.');
var imgCOM = imgSPL[0] +'-g.'+ imgSPL[1];
$("img", this).attr("src", imgCOM);
$(this).removeAttr('href');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment