diff --git a/godoc/static/godocs.js b/godoc/static/godocs.js index 23a580e5..5177c302 100644 --- a/godoc/static/godocs.js +++ b/godoc/static/godocs.js @@ -245,9 +245,15 @@ function fixFocus() { } function toggleHash() { + var id = window.location.hash.substring(1); // Open all of the toggles for a particular hash. - var els = $(document.getElementById(window.location.hash.substring(1)), - $.find("a[name='" + window.location.hash.substring(1) + "']")); + var els = $( + document.getElementById(id), + $('a[name]').filter(function() { + return $(this).attr('name') == id; + }) + ); + while (els.length) { for (var i = 0; i < els.length; i++) { var el = $(els[i]); diff --git a/godoc/static/static.go b/godoc/static/static.go index 6fab8da3..2d478afc 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -815,9 +815,15 @@ function fixFocus() { } function toggleHash() { + var id = window.location.hash.substring(1); // Open all of the toggles for a particular hash. - var els = $(document.getElementById(window.location.hash.substring(1)), - $("a[name='" + window.location.hash.substring(1) + "']")); + var els = $( + document.getElementById(id), + $('a[name]').filter(function() { + return $(this).attr('name') == id; + }) + ); + while (els.length) { for (var i = 0; i < els.length; i++) { var el = $(els[i]);