使用jquery操作选择框

我想使用jquery更改页面的字体,所以这里 HTML:
<p>Content Font:</p>
<select name="content_fonts">
<option value="volvo">Arial</option>
<option value="saab">Gerogia</option>
<option value="fiat" selected="selected">Times New Roman</option>
<option value="audi">verdana</option>
</select>
jQuery的:
$('#contant_fonts').click(function(){
   $('.leftpanel').css('font-family',"Times New Roman", Times, serif"));
});
但它似乎工作谢谢     
已邀请:
你需要一些报价调整,你的选择器关闭,如下所示:
$('select[name="content_fonts"]').click(function(){
   $('.leftpanel').css('font-family','"Times New Roman", Times, serif');
});
虽然我认为你所追求的是:
$('select[name="content_fonts"]').change(function(){
    $('.leftpanel').css('font-family', $(this).find(":selected").text());
});
你可以在这里测试一下。     
只需看看你的代码
$('.leftpanel').css('font-family',"Times New Roman", Times, serif"));
css
的第二个参数是一个字符串,所以如果你需要在该字符串中传递Double Quotes,它不应该破坏参数本身。
$('.leftpanel').css('font-family','"Times New Roman", Times, serif'));
看尼克克拉弗的答案。 或者你甚至可以逃脱(
"
)双引号。 问题在于你的引号不在jQuery中。或Javascript。     

要回复问题请先登录注册