gpt4 book ai didi

javascript - 将行中的数据显示到 jquery 弹出对话框

转载 作者:行者123 更新时间:2023-11-28 06:46:06 27 4
gpt4 key购买 nike

如何在弹出表单的文本框中显示值。

function eopen(id) {    
edialog.dialog("open");
item_id = id;
//show id in span field.
$('#item-id').text(item_id);
//how to show related columns for a id in text box below..
$('#editname').val(??????);

这是从数据库加载的数据内容...

echo '<div><span class="item-name">'. $item[$i]['gitem_name'] . '</span>';
echo '<a class="edit-name" id="'. $item[$i]['gitem_id'] .'">edit</a>';

这是我用于值编辑的点击功能..

$('.edit-name').click(function (e) {
e.preventDefault();
eopen($(this).attr("id"));
});

这是弹出表单值..

<span>Global ID : </span><span id="item-id" class="dialog-text"></span>
<input type="text" id="editname" style="width: 100%;" name="editname">

最佳答案

使用.closest .find

function eopen(id) {    
edialog.dialog("open");
item_id = id;
//show id in span field.
$('#item-id').text(item_id);
var value=$("#"+id).closest('div').find('.item-name').text();
//get its parent with .closest and find item-name in it and get its text
$('#editname').val(value);
}

关于javascript - 将行中的数据显示到 jquery 弹出对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33409045/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com