zoukankan      html  css  js  c++  java
  • JavaScript--'data-'的用法(1)

    HTML5为我们提供了一个强大的功能,前段也也能实现后台数据库的效果,例如data-xxx

     <a href="#myModal" data-industry_id="{$industry_info.industry_id}" class="del_btn" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a>
    

      其中,我在data-industry_id中存放了一个数据,我要拿出来,就:

    <script type="text/javascript">
    	//获取数据
        var industry_id = '';
        $('.del_btn').click(function(){
            industry_id = $(this).attr('data-industry_id');
        });
    

      其中id='del_btn'的我为他设置了一个点击事件,以点击他就获取 data-industry_id 的数据,这样就可以取出来了。

          如果其中href如果被占据了,则可以在JavaScript设置:

        //点击事件
        $('.btn-danger').click(function(){
            window.location.href = '{:U("Industry/industry_delete")}?industry_id=' + industry_id;
        });
    

      

  • 相关阅读:
    FILTER(过滤器)
    HDFS优缺点
    python运算符
    python变量类型
    python变量存储
    python编码问题
    【一:定义】python 简介
    如何学一门新技术
    Django安装
    redis 安装及启动关闭
  • 原文地址:https://www.cnblogs.com/laijinquan/p/7442786.html
Copyright © 2011-2022 走看看