我试图避免以下情况:
var dynS = $('#dyn-style');
var cssA = $('#css-active');
$('#selectors li').click(function(){
switch($(this).attr('data-id')){
case 'first-of-type':
dynS.empty().text('#target p:first-of-type {color: red;}');
cssA.empty().text('#target p:first-of-type {color: red;}');
有什么办法可以使用缓存的选择器变量并将 text() 设置为两者相同,以避免这种重复?