您正在加载DOM之前运行代码。
尝试这个:
现场示例:
$(function() { // Makes sure the pre contained doesn't run until // all the DOM elements have loaded $('#colorselector').change(function(){ $('.colors').hide(); $('#' + $(this).val()).show(); });});


