我正在创建一个完整的可编辑菜单并遇到一个奇怪的问题。我制作了用于编辑菜单按钮文本的脚本,它隐藏了链接并将输入附加到 div。这是代码:
$('#edit_button').click(function() {
var temp = id;
$("#" + temp + " a").hide("fast", function(){
if($("#link_editor").length > 0){
var temp_id = $("#link_editor").parent().attr("id");
$("#link_editor").hide("fast", function(){
$("#link_editor").remove();
$("#" + temp_id + " a").show("fast");
});
}
$("<input type='text' id='link_editor' value='" + $("#" + temp + " a").html() + "'>").hide().appendTo("#" + temp).show("fast");
});
});
菜单看起来像这样 => 主页博客联系人 所以当我先点击主页,然后点击博客等 - 一切正常,但如果我从联系人开始并返回它不起作用。您可以在此处查看实时示例。只需将鼠标悬停在任何菜单按钮上,然后单击编辑图标。鼠标悬停时接收全局 ID。
这是菜单代码:
<div id="sortable" class="ui-sortable">
<div id="0"><a href="?page=Home" id="0" class="prevent_doubleclick" title="" style="display: block; ">Home</a></div>
<div id="1"><a href="?page=Gallery" id="1" class="prevent_doubleclick" title="" style="display: block; ">Gallery</a></div>
<div id="2"><a href="?page=Blog" id="2" class="prevent_doubleclick" title="" style="display: block; ">Blog</a></div>
<div id="3"><a href="?page=About" id="3" class="prevent_doubleclick" title="" style="display: none; ">About</a><input type="text" id="link_editor" value="About" style=""></div>
<div id="4"><a href="?page=Contact" id="4" class="prevent_doubleclick" title="">Contact</a></div>
<div class="add_button" style="margin-top: -10px; display: none; "><a style="cursor: pointer; text-decoration: none;"><img src="/img/add.png">Add Button</a></div>
</div>
任何帮助将不胜感激,谢谢。