Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
onchange和jQuery val()和text()存在问题_Jquery - Fatal编程技术网

onchange和jQuery val()和text()存在问题

onchange和jQuery val()和text()存在问题,jquery,Jquery,我有一个像这样的文本区域,我现在写在里面 现在我想在更改后,文本区域内容会显示在一个pre中 我曾经 函数perview(){ var code=$(“textarea#content”).val(); $('#代码预览').html(代码); } 我觉得一切都好 <pre id="code-preview"></pre> 但在pre上使用highlighter时,它不起作用 那样 <pre id="code-preview" class="bru

我有一个像这样的文本区域,我现在写在里面 现在我想在更改后,文本区域内容会显示在一个pre中 我曾经


函数perview(){
var code=$(“textarea#content”).val();
$('#代码预览').html(代码);
}   
我觉得一切都好

<pre id="code-preview"></pre> 

但在pre上使用highlighter时,它不起作用 那样

<pre id="code-preview" class="brush: php;"></pre>

荧光灯 版本2.1.364(2009年10月15日)

请尝试使用

$(document).ready(function(){
     $('textarea#content').change(function(){
          var code = $(this).val();
          $('#code-preview').html(code);
     });
});
您可能还想尝试其他一些方法,例如.blur()instad of.change()

同时,还应移除:;从你们班来的。应改为:

<pre id="code-preview" class="brush:php"></pre>

我希望这会有所帮助。

不要使用onchange=“”,请尝试使用

$(document).ready(function(){
     $('textarea#content').change(function(){
          var code = $(this).val();
          $('#code-preview').html(code);
     });
});
您可能还想尝试其他一些方法,例如.blur()instad of.change()

同时,还应移除:;从你们班来的。应改为:

<pre id="code-preview" class="brush:php"></pre>

我希望这对你有帮助。

你试过了吗

function perview() {
   var code = $("textarea#content").val();
    $('#code-preview').html(code);
    SyntaxHighlighter.all() // <--- calling this again...
} 
function perview(){
var code=$(“textarea#content”).val();
$('#代码预览').html(代码);
SyntaxHighlighter.all()/你试过了吗

function perview() {
   var code = $("textarea#content").val();
    $('#code-preview').html(code);
    SyntaxHighlighter.all() // <--- calling this again...
} 
function perview(){
var code=$(“textarea#content”).val();
$('#代码预览').html(代码);

SyntaxHighlighter.all()//什么确切地说它不是那样工作的?没有highlighter它能工作吗?我假设,highlighter只处理页面加载时的
标记。
class=“brush:php;”
一点也不正确。
class
是一个以空格分隔的类名列表,您的类名看起来更符合
样式
属性。不,高亮灯工作得很好,但当更改文本时,它在高亮灯中没有更改。这到底意味着它没有这样工作吗?没有高亮灯它工作吗?我想,高亮显示仅处理页面加载时的标签。
class=“brush:php;”
一点也不正确。
class
是一个以空格分隔的类名列表,您的类名看起来更符合
样式
属性。不,高亮灯工作得很好,但是当更改文本时,高亮灯没有更改。什么是反对票?如果是关于类修复,那么您知道它实际上是他使用的一个插件叫做syntax highlighter,它要求你使用class=“brush:php”或brush:js等等。下面的例子是:反对票是怎么回事?如果是关于类修复,那么你知道它实际上是他使用的一个插件的一部分,叫做syntax highlighter,它要求你使用class=“brush:php”或笔刷:js等等。下面是示例: