Skip to content

Instantly share code, notes, and snippets.

@benjaminfisher
Last active August 29, 2015 14:13
Show Gist options
  • Save benjaminfisher/90f593f1280f46e85a88 to your computer and use it in GitHub Desktop.
Save benjaminfisher/90f593f1280f46e85a88 to your computer and use it in GitHub Desktop.
JS: Test that TD element width matchs declared width (jQuery)
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
<script>
$(function(){
$('<p>').html('Width').prependTo('body');
$('tr').each(function(){
$(this).children('td').each(function(i){
var $this = $(this);
if(!$this.attr('colspan') && !($this.width() == $this.attr("width"))){
console.log("width:", $this.width(), " attr:", $this.attr("width"));
console.log(this);
$(this).css("outline", "1px solid red");
}
})
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment