62,271
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function(){
setClickable();
});
function setClickable()
{
$('editDiv').click(function(){
var textarea='<div><textarea rows="10" cols="60">'+$(this).html()+'</textarea>';
var button='<div><input type="button" value="SAVE" class="saveButton"/> or <input type="button" value="CANCEL" class="cacelButton"/></div></div>';
var revert=$(this).html();
});
$(this).after(textarea+button).remove();
$('.saveButton').click(function(){saveChanges(this,false);});
$('.cancelButton').click(function(){saveChanges(this,revert);});
.mouseover(function(){
$(this).addClass("editable");//说是这里有语法错误
})
.mouseout(function(){
$(this).removeClass("editable");
});
};

$(document).ready(function(){
setClickable();
});
function setClickable()
{
$('#editDiv').click(function(){
var textarea='<div><textarea rows="10" cols="60">'+$(this).html()+'</textarea>';
var button='<div><input type="button" value="SAVE" class="saveButton"/> or <input type="button" value="CANCEL" class="cacelButton"/></div></div>';
var revert=$(this).html();
});
//$(this).after(textarea+button).remove();
$('.saveButton').click(function(){saveChanges(this,false);});
$('.cancelButton').click(function(){saveChanges(this,revert);});
$('#editDiv').mouseover(function(){
$(this).addClass("editable");
})
$('#editDiv').mouseout(function(){
$(this).removeClass("editable");
});
};
function saveChanges(obj,cancel)
{
if(!cencel)
{
var t=$(obj).parent().siblings(0).val();
$.post("test2.php",{content:t},function(txt){alert(txt);});
}
else
{
var t=cancel;
}
$(obj).parent().parent().after('<div id="editDiv">'+t+'</div>').remove();
setClickable();
}
<body>
<form id="form1" runat="server">
<div id="editDiv">
啊大大所得税法岗位上各色
</div>
</form>
</body>
</html>
如果是ID为editDiv层
$('#editDiv').mouseover(function(){
$(this).addClass("editable");//说是这里有语法错误
})
$('#editDiv').mouseout(function(){
$(this).removeClass("editable");
});
如果是class为editDiv的层。把#改成.
如果是ID为editDiv层
$('#editDiv')..mouseover(function(){
$(this).addClass("editable");//说是这里有语法错误
})
$('#editDiv')..mouseout(function(){
$(this).removeClass("editable");
});
如果是class为editDiv的层。把#改成.



$(document).ready(function(){
setClickable();
});
function setClickable()
{
$('#editDiv').click(function(){
var textarea='<div><textarea rows="10" cols="60">'+$(this).html()+'</textarea>';
var button='<div><input type="button" value="SAVE" class="saveButton"/> or <input type="button" value="CANCEL" class="cacelButton"/></div></div>';
var revert=$(this).html();
$(this).after(textarea+button).remove();
$('.saveButton').click(function(){saveChanges(this,false);});
$('.cancelButton').click(function(){saveChanges(this,revert);});
});
$('#editDiv').mouseover(function(){
$(this).addClass("editable");
})
$('#editDiv').mouseout(function(){
$(this).removeClass("editable");
});
}
function saveChanges(obj,cancel)
{
if(!cancel)
{
var t=$(obj).parent().siblings(0).val();
$.post("test2.php",{content:t},function(txt){alert(txt);});
}
else
{
var t=cancel;
}
$(obj).parent().parent().after('<div id="editDiv">'+t+'</div>').remove();
setClickable();
}
<form id="form1" runat="server">
<div id="editDiv" style=" width:300px; height:300px;">
啊大大所得税法岗位上各色
</div>
</form>