diff --git a/src/librustdoc/html/static/playpen.js b/src/librustdoc/html/static/playpen.js
index 473a20086ed..f7d6b872940 100644
--- a/src/librustdoc/html/static/playpen.js
+++ b/src/librustdoc/html/static/playpen.js
@@ -14,6 +14,7 @@
(function() {
if (window.playgroundUrl) {
$('pre.rust').hover(function() {
+ if (!$(this).attr('id')) { return; }
var id = '#' + $(this).attr('id').replace('rendered', 'raw');
var a = $('').text('⇱').attr('class', 'test-arrow');
var code = $(id).text();