Dojo, how to do onclick event on a DIV

本小妞迷上赌 提交于 2019-12-04 07:04:18
seth

If I understand what you are trying to do, I think you can accomplish it with this:

HTML

 <div id='parentNode'> 
    <div id='textDiv'> 
      <div id='iconDiv'>this is icon div</div> 
      <div id='messageDiv'>this is message div</div> 
    </div> 
 <div> 

JavaScript

// do it when the DOM is loaded
dojo.addOnLoad( function() {
  // attach on click to id="textDiv"
  dojo.query('#textDiv').onclick( function(evt) { 
    // 'this' is now the element clicked on (e.g. id="textDiv")
    var el = this; 
    // set opacity
    dojo.style(this, "opacity","1"); 
    // do fade out
    dojo.fadeOut({ 
      node: this, 
      duration: 2000, 
      // pass in an onEnd function ref that'll get run at end of animation
      onEnd: function() { 
        // get rid of it     
        dojo.query(el).orphan() 
      } 
    }).play() 
  });
});

The click will bubble up so it'll be caught by textDiv.

Here are some helpful links:

Let me know if I misunderstood your question and I'll update my answer. Hope this helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!