1

在下面给出的 jsfiddle 链接中,有 2 个按钮,单击其中任何一个按钮都会显示一个工具提示。我希望工具提示内的按钮更改“删除”文本和“输入文本”的显示和其他属性(使文本字段可编辑)问题是值确实更新但文本仍然无法编辑“请提出问题的解决方案

JSFIDDLE

HTML

<button id="gear">Gear</button>
<button id="gear1">Gear</button>
<div style="display:none;" id="menu">
    <button class="menuitem">Rename</button><br>
    <input type= "text" id = "try" readonly = "true"><br>
    <div id = "delete" style = "display: block">Delete</div><br>
</div>

​</p>

JavaScript

$(function() {
    $("#gear").button({
        icons: {
            primary: "ui-icon-gear",
            secondary: "ui-icon-triangle-1-s"
        },
        text: false
    }).qtip({
        content: {
            text: $('#menu')
        },
        show: {
            event: 'click',
            solo: true,
            modal: true
        },
        style: {
            classes: 'ui-tooltip-dark ui-tooltip-shadow'
        },
        position: {
            my: 'top center',
            at: 'bottom center',
        }
    });
     $("#gear1").button({
        icons: {
            primary: "ui-icon-gear",
            secondary: "ui-icon-triangle-1-s"
        },
        text: false
    }).qtip({
        content: {
            text: $('#menu')
        },
        show: {
            event: 'click',
            solo: true,
            modal: true
        },
        style: {
            classes: 'ui-tooltip-dark ui-tooltip-shadow'
        },
        position: {
            my: 'top center',
            at: 'bottom center',
        }
    });
    $(".menuitem").click(function(){
        document.getElementbyId("try").readOnly = false;
        document.getElementbyId("delete").style.display = none;                alert($(this).text());
    });
});​

CSS

#gear {
    margin:100px;
}
.menuitem {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 9px;
    margin-bottom: 3px;
    width: 75px;
}
4

1 回答 1

0

我可以建议你使用 jquery 选择器:

$(".menuitem").click(function(){
    $("#try").attr('readonly', false);
    $("#delete").hide();
    alert($(this).text());
});
于 2013-08-11T13:02:53.813 回答