English 中文(简体)
在被点击后,我如何躲藏或淡化 j中的选择?
原标题:How to I hide or disable a choice in the context menu in javascript after clicking it?

我有四种选择的环境菜单,我想在点击后隐藏或去掉一种选择。 这些是我的文字碎片。 在我点击“挽救方案”之后,每当我右边再次点击时,我只想在地表上提供“Move”方案。 drag是干类。 是可能的?

var menu = [
            { Move :function(menuItem,menuObject){
                    $(this).css({ backgroundColor : red });
                    return true; 
                } 
            },
            { Save :function(menuItem,menuObject){
                    $(this).css({ backgroundColor : blue });
                    return true;
                }
            }
        ];

$(function() {
            $( .drag ).contextMenu(menu,{
                showSpeed:500,
                hideSpeed:500,
                showTransition: fadeIn ,
                hideTransition: fadeOut 
            });
        });

预 收

问题回答

First of all the class drag is the class of the parent element. So you have to find the class of the "save" element. Lets suppose the class is .save, then on click remove it. This is done with this code:

$(".save").click(function{
 $(this).remove();
})

如果你再次点击,该要素将再次建立,上述职能将失去目的。 正如我能看到的那样,这是你的问题。

但是,为什么在“挖掘”之后,你需要藏匿的纽子? 或许用户希望再次储蓄。

如果我们能看到一种mo,了解你试图执行的东西,那将是有益的。

If you try to apply a rule only on changed (dragged) element you have to flag the changed ones in the class or in your db which holds the positions of the elements. Then you can manipulate only the flagged (changed) through the jquery selector.

if ((.drag).hasClass( .changed )){
  $(".save").css({"visibility: visible"});
}

不要忘记不实地隐藏在 c中。

.save{visibility: none}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签