鉴于以下标记和 JS,为什么第一个语句有效而第二个语句无效?
jQuery
$('.selector').change(function () {
// does work
$(this).parent(".controls").after( "<div class=\"control-group\">Test</div>" );
// doesn't work
$(this).parent(".control-group").after( "<div class=\"control-group\">Test</div>" );
}
HTML
<div class="control-group">
<label class="control-label" for="description">Section Type</label>
<div class="controls">
<select class="selector">
// options
</select>
</div>
</div>