zoukankan      html  css  js  c++  java
  • js比较常用的

    1.

    <a href="javascript:void(0);" id="div1_bu" >点击链接可以删除div2</a>

    超链接的功能:
    1.可以被点击:有样式:(1.蓝颜色的 2.鼠标放上去变小手 3.有下划线 4.点击时闪动一下 5.用于绑定js事件,onclick,点击后不跳转但有反应显示和执行js代码,)
    2.点击后跳转到href指定的url(此时设置href为空,是href=""。相当于在当前页面跳转,即刷本页。)
    需求:想保留1的功能,去掉2功能
    实现:href="javascript:void(0);"
    2.
    <tr>
    <th>1</th>
    <th>韩韩</th>
    <th>男</th>
    <th><a href="#" name="delete" onclick="fun(this);">删除</a></th>
    <!--因为删除时不容易用id查找点击那个删除有点困难。就直接给a标签设置一个onclick属性,在fun方法里传递一个this,在js里用特殊用处-->
    </tr>
    <tr>
    <th>2</th>
    <th>丽丽</th>
    <th>女</th>
    <th><a href="#" name="delete" onclick="fun(this);">删除</a></th>
    </tr>
    function fun(o) {   //括号里面要放一个形参接收传来的this,this代表点击的那个a标签元素
    var th_a = o.parentNode;
       var tr = th_a.parentNode;
       var table = tr.parentNode;
       table.removeChild(tr);
    }
    .....来自:Dom_Test01.html
    与其战胜敌人一万次,不如战胜自己一次。
  • 相关阅读:
    springboot缓存-Ehcache
    springboot+spring data jpa 多数据源配置
    vue+element 上传图片控件
    springboot下载文件
    easyPoi导入带图片的excel
    内外网同时使用(宽带内网无线内网)
    mysql 8.0 安装
    搭建一个Vue前端项目
    mybatis反向代理自动生成mapper文件
    【1】idea Live Templates
  • 原文地址:https://www.cnblogs.com/hyjh/p/11186476.html
Copyright © 2011-2022 走看看