Php 我想通过单击edit来选择整行进行编辑
在这里,我只能在一个元素上看到框,这是我为编辑选择的元素。我想在单击“编辑”时看到所有元素上的框。我该怎么处理 这是我的密码Php 我想通过单击edit来选择整行进行编辑,php,javascript,jquery,mysql,Php,Javascript,Jquery,Mysql,在这里,我只能在一个元素上看到框,这是我为编辑选择的元素。我想在单击“编辑”时看到所有元素上的框。我该怎么处理 这是我的密码 <!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function mDown(obj) {
obj.innerHTML="update"
}
function mUp(obj) {
obj.innerHTML="update"
}
jQuery(document).ready(function(){
jQuery("form").submit(function(){
//alert("Submitted");
jQuery("#myform").submit();
});
$('.edit').click(function(){
//alert("Submitted");
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
$(this).addClass('ajax');
$(this).html('<input id="editbox" size="'+
$(this).text().length+'" value="' +
$(this).text() + '" type="text">');
$('#editbox').focus();
});
$('.edit').keydown(function(event){
// alert("Submitted");
arr = $(this).attr('class').split( " " );
if(event.which == 13) {
$.ajax({
type: "POST",
url:"config.php",
data: "value="+$('.ajax input').val()+"&rownum="+arr[2]+"&field="+arr[1],
success: function(data){
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
}});
}
});
$('#editbox').live('blur',function(){
$('.ajax').html($('.ajax input').val());
$('.ajax').removeClass('ajax');
});
$('td.delete1').on('click',function() {
//alert("Submitted");
var parent = $(this).closest('tr');
$.ajax({
type: 'get',
url: 'dl.php', // <- replace this with your url here
data: 'ajax=1&delete=' + $(this).attr('id'),
beforeSend: function() {
parent.animate({'backgroundColor':'#fb6c6c'},300);
},
success: function() {
parent.fadeOut(300,function() {
parent.remove();
});
}
});
$('.delete').confirm({
msg:'Do you really want to delete this?',
timeout:3000
});
});
});
功能mDown(obj){
obj.innerHTML=“更新”
}
功能mUp(obj){
obj.innerHTML=“更新”
}
jQuery(文档).ready(函数(){
jQuery(“表单”).submit(函数(){
//警报(“已提交”);
jQuery(“#myform”).submit();
});
$('.edit')。单击(函数(){
//警报(“已提交”);
$('.ajax').html($('.ajax输入').val());
$('.ajax').removeClass('ajax');
$(this.addClass('ajax');
$(this.html(“”);
$(“#编辑框”).focus();
});
$('.edit').keydown(函数(事件){
//警报(“已提交”);
arr=$(this.attr('class').split(“”);
如果(event.which==13){
$.ajax({
类型:“POST”,
url:“config.php”,
数据:“value=“+$('.ajax input').val()+”&rownum=“+arr[2]+”&field=“+arr[1]”,
成功:函数(数据){
$('.ajax').html($('.ajax输入').val());
$('.ajax').removeClass('ajax');
}});
}
});
$('#editbox').live('blur',function(){
$('.ajax').html($('.ajax输入').val());
$('.ajax').removeClass('ajax');
});
$('td.delete1')。在('click',function()上{
//警报(“已提交”);
var parent=$(this).closest('tr');
$.ajax({
键入:“get”,
url:'dl.php',//您的$(this)将保存您单击的唯一元素。
所以
然后为“p”元素获取所有子节点。
并为所有子元素使用for循环,为每个元素添加上述代码,而不是为$(this)
$(this).addClass('ajax');
$(this).html('<input id="editbox" size="'+
$(this).text().length+'" value="' +
$(this).text() + '" type="text">');
var p = $(this).parentNode;