js绑定的一种用法

 <a class=" " href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="show(getCallback(<%= record.id %>))">函数</a>
              
    <div style="display: none; height: 412px; width: 300px;" id="hang">
                 <ul style="list-style-type:none; padding-right:30px;">
                        <a style="height:48px;" class="nav-link text-center link" href="#"  id="btnOk">  <strong>确定</strong> </a>
                 </ul>
  </div>
               
  <script>
  // 参数 (函数也可以作为参数)
  function getCallback(recordId) {
    return function() {
      $("#btnOk").unbind();
      $("#btnOk").click(function() {
         // alert(recordId);
          return record;
        }
      )
    }
  }
 
  function show(callback){
    var recordId=callback();
    $("#hang").show();
  }
  function hide(){ $("#hang").hide()}
 
</script>                             

div 隐藏的,show()函数功能是显示div,show参数绑定了另一个函数getCallback()。getVCallback中绑定了 btnOk 超链接的click事件。

猜你喜欢

转载自blog.csdn.net/liguangix/article/details/84401424