JQuery .html()和.text()在Production中返回空值

use*_*525 1 html jquery

我有一个带有posttext的文本区域.

我试图获取textarea的值,但.html()和.text()始终在Production中返回null.但.val()返回正确的值.我使用IIS作为Web服务器.

alert($("#posttext").html());    // returns empty
alert($("#posttext").val());     //returns the correct values
alert($("#posttext").text());    // returns empty
Run Code Online (Sandbox Code Playgroud)

当我在本地运行时,代码工作正常,那么是否有任何设置在生产中搞砸了?有什么办法调试?由于它是一个ajax加载形式,我无法在视图源中看到textarea.

谢谢

jfr*_*d00 6

在jQuery中,您可以使用.val()访问textarea的内容.这就是jQuery的工作原理.你不使用.html().text().你的解决方案似乎很简单.只是用.val().

.html().text()返回原始HTML中的值,它是textarea的初始值,而不是当前键入的值.

http://jsfiddle.net/jfriend00/zV5zM/