Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
Javascript jqueryeditpost不';行不通_Javascript_Jquery - Fatal编程技术网

Javascript jqueryeditpost不';行不通

Javascript jqueryeditpost不';行不通,javascript,jquery,Javascript,Jquery,我正在尝试使用jquery制作一篇编辑文章。但我的代码不起作用。 当我单击编辑按钮时,它需要工作,然后editMarkUp将被放入messageB1,但它不工作 任何人都可以帮助我,我缺少什么,解决办法是什么 这是来自jsfiddle.net的 Js $(文档).ready(函数(){ $(“body”)。在(“click”,“.editBtn”,function()上{ var ID=$(this.attr(“ID”); var currentMessage=$(“#messageB”+ID+

我正在尝试使用jquery制作一篇编辑文章。但我的代码不起作用。 当我单击编辑按钮时,它需要工作,然后
editMarkUp
将被放入
messageB1
,但它不工作

任何人都可以帮助我,我缺少什么,解决办法是什么

这是来自jsfiddle.net的

Js

$(文档).ready(函数(){
$(“body”)。在(“click”,“.editBtn”,function()上{
var ID=$(this.attr(“ID”);
var currentMessage=$(“#messageB”+ID+”.postInfo”).html();

var editMarkUp=''+currentMessage+'您没有在代码中的任何地方定义
editobj
变量,我猜您的意思可能是
。postInfo

$(document).ready(function() {

  $("body").on("click", ".editBtn", function() {
    var ID = $(this).attr("id");
    $('.postInfo').prop('disabled', 'true');
    var currentMessage = $("#messageB" + ID + " .postInfo").html();
    var editMarkUp = '<textarea rows="5" cols="80" id="txtmessage_' + ID + '">' + currentMessage + '</textarea><button name="ok" ">Save</button><button name="cancel">Cancel</button>';
    $("#messageB" + ID + " .postInfo").html(editMarkUp);
  });
});   
$(文档).ready(函数(){
$(“body”)。在(“click”,“.editBtn”,function()上{
var ID=$(this.attr(“ID”);
$('.postInfo').prop('disabled','true');
var currentMessage=$(“#messageB”+ID+”.postInfo”).html();

var editMarkUp=''+currentMessage+'您有
未捕获的引用错误:在ConsoleAnk You中未定义editobj
。很抱歉,我正在学习这个问题:)。再次感谢。没问题。当您测试代码时,您可以使用浏览器的Web开发工具中的优秀工具,学习;)
<div class="container">
   <div class="postAr" id="messageB1">
      <div class="postInfo">
         fdasfads fasd fadsf adsf adsf adsf asd fasd f dfsa
      </div>
      <div class="editBtn" id="1">Edit</div>
   </div>
</div>
$(document).ready(function() {

  $("body").on("click", ".editBtn", function() {
    var ID = $(this).attr("id");
    $('.postInfo').prop('disabled', 'true');
    var currentMessage = $("#messageB" + ID + " .postInfo").html();
    var editMarkUp = '<textarea rows="5" cols="80" id="txtmessage_' + ID + '">' + currentMessage + '</textarea><button name="ok" ">Save</button><button name="cancel">Cancel</button>';
    $("#messageB" + ID + " .postInfo").html(editMarkUp);
  });
});