首页 \ 问答 \ MIDP堆与VM堆(MIDP heap vs VM heap)

MIDP堆与VM堆(MIDP heap vs VM heap)

一些Java移动设备对于MIDP和VM具有不同的堆。 这两个堆之间的区别是什么,以及如何将J2ME应用程序控件用于给定数据?


Some Java mobile devices have distinct heaps for MIDP and VM. What's the distinction between these two heaps, and how can a J2ME app control which is used for a given piece of data?


原文:https://stackoverflow.com/questions/439721
更新时间:2023-11-13 17:11

最满意答案

您的代码正在做的是在构建初始DOM时设置回调。 当然,还没有#menuResp2。 Insdead,在文档元素(或正文或其他一些父元素)上设置回调,指定菜单的选择器 - 此元素将触发事件。 这将有效:

$(document).ready(function () {
    $(document).on('click', "#menuResp", function () {

        $('#profile_menu').css('margin-left','0px');
        $('#menuResp').css('margin-left','315px');
        $('#menuResp').attr('id', 'menuResp2')

    }).on('click', "#menuResp2", function () {

        $('#profile_menu').css('margin-left','-300px');
        $('#menuResp2').css('margin-left','0px');
        $('#menuResp2').attr('id', 'menuResp')

    });
});

但。 我强烈建议不要更改ID属性,而是改为使用类。


What your code is doing is setting callbacks at the moment, when the initial DOM is being built. Of course, there is no #menuResp2 yet. Insdead, set the callback on the document element (or body, or some other parent element), specifying the selector of your menu - this element will fire the event. This will work:

$(document).ready(function () {
    $(document).on('click', "#menuResp", function () {

        $('#profile_menu').css('margin-left','0px');
        $('#menuResp').css('margin-left','315px');
        $('#menuResp').attr('id', 'menuResp2')

    }).on('click', "#menuResp2", function () {

        $('#profile_menu').css('margin-left','-300px');
        $('#menuResp2').css('margin-left','0px');
        $('#menuResp2').attr('id', 'menuResp')

    });
});

But. I would stroungly recommend not to change the ID attribute, but to work with classes instead.

相关问答

更多
  • 由于某些浏览器(取决于DOCTYPE)能够容忍onClick="something();" 属性......它似乎已经分散了一些,甚至在JavaScript不起作用的问题上,因为这个问题很重要。 此外,具体到stackoverflow ...在问题中使用它的人...以及,大多数时候他们不会问一个问题,如果他们的代码工作:) Because some browsers (depending on the DOCTYPE) are tolerant of the inline onClick="somethin ...
  • 总结您的问题您希望能够通过单击执行两个同步操作 解决方案使用anchor元素中的onclick属性,调用JavaScript函数在javascript脚本中,将此对象传递给该函数 然后函数接收到我们可以调用el的对象,然后将对象转发到其他两个函数中 HTML JavaScript的 function funAchorClick(el){ funProcessOne(el); funProces ...
  • 首先,了解您有三种语言在一起工作。 PHP:仅由服务器运行并响应点击链接(GET)或提交表单(POST)等请求。 HTML和JavaScript:只能在某人的浏览器中运行(不包括NodeJS)。 我假设你的文件看起来像: ...
  • 这可以帮助 private int clicks = 0; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Button b = (Button)v; if (clicks == 0){ // Means its the first time that a user c ...
  • 首先,您应该在问题中添加更多代码,以便获得最佳答案。 我的意思是没有冒犯! 其次,你不应该像那样写INLINE JAVASCRIPT,这是一个不好的做法。 你可以这样做: HTML: Click Here JS: $(function){ //document ready function $("#myBtn").on("click", function(){ // Do what you want to do here! callNextFunc ...
  • 最简单的方法是停止onclick事件从anchor标签到div的传播(冒泡)。 只需将一个onclick事件添加到锚点并将处理程序设置为: event.cancelBubble = true; if(event.stopPropagation) { event.stopPropagation(); } 这是跨浏览器代码。 在IE,FF,Chrome,Safari中测试过。 所以你的代码现在应该是这样的: