我想在文本区域中显示样式表内容是用户在选择框中选择样式。样式表在服务器中,所以我尝试加载,并且两者都不起作用。
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#sel').change(function() {
jQuery.get('style1.css',function(data) {
jQuery('#cs').html(data);
alert('Load was performed.');
});
// jQuery('#cs').load('style1.css');
});
});
</script>
HTML
<select id="sel">
<option value="style1">style1</option>
<option value="style2">style2</option>
</select>
我正在加载已执行警报但未执行文本区域中的内容。
此处#cs
是我的文字区域的ID。
答案 0 :(得分:1)
使用val()
而不是html()
设置textarea的值。
答案 1 :(得分:1)
你需要使用val。
jQuery(document).ready(function(){
jQuery('#sel').change(function() {
jQuery.get('style1.css',function(data) {
jQuery('#cs').val(data);
alert('Load was performed.');
});
// jQuery('#cs').load('style1.css');
});