记录一下各种隐藏html元素的方法

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
<script type="text/javascript" src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="rrapp">
<input type="button" value="Vue隐藏DIV" v-on:click="testdisplay1()">
<input type="button" value="根据ID隐藏DIV" v-on:click="testdisplay2()">
<input type="button" value="根据ID隐藏DOM" v-on:click="testdisplay3()">
<input type="button" value="根据类型隐藏标签" v-on:click="testdisplay4()">
<input type="button" value="根据class隐藏DIV" v-on:click="testdisplay5()">
<br/><br/><br/>
<div v-show="isdisplay" style="width: 100px;height: 100px;background: red">test1</div>
<div id="test2" style="width: 100px;height: 100px;background: yellow">test2</div>
<input type="button" id="test3" value="确定"/>
<p>测试P标签隐藏</p>
<div class="test5" >测试隐藏class一样的DIV</div>
<div class="test5" >测试隐藏class一样的DIV</div>
</div>
<script type="text/javascript">
var vm = new Vue({
el:'#rrapp',
data:{
isdisplay:true,
},
methods:{
testdisplay1:function(){
vm.isdisplay = !vm.isdisplay;
},
testdisplay2:function(){
$("#test2").css("display", "none");
},
testdisplay3:function(){
$('#test3').hide();
},
testdisplay4:function(){
$("p").hide();
},
testdisplay5:function(){
$(".test5").hide();
}
}
});
</script>
</body>
</html>

hidden是html中的属性,规定元素是否可见
display是css中的样式,规定元素是否显示
visible 是css中的样式,规定元素是否可见
display:none ---不为被隐藏的对象保留其物理空间,即该对象在页面上彻底消失,通俗来说就是看不见也摸不到。
visible:hidden--- 使对象在网页上不可见,但该对象在网页上所占的空间没有改变,通俗来说就是看不见但摸得到。
$("#id").hide()实际上是设置了css中的display为none,$("#id").show()实际上是设置了css中的display为block。这一点通过查看jQuery源码可知。

css里面的display会覆盖html中的hidden属性

隐藏网页中DIV和DOM的各种方法的更多相关文章

  1. 网页中插入javascript的几种方法

    网页中插入javascript的方法常见的有两种: 一.直接使用html标记 JavaScript 可以出现在 html的任意地方.使用标记<script>…</script> ...

  2. 网页中Div的打印

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  3. JS获取网页中HTML元素的几种方法分析

    getElementById getElementsByName getElementsByTagName 大概介绍 getElementById ,getElementsByName ,getEle ...

  4. jQuery动态显示和隐藏datagrid中的某一列的方法

    在EasyUI中: 1)展示某列的方法:     $('#jgrid').datagrid('showColumn', 'XXX');  -----其中 XXX 是隐藏列的  field 属性值 2) ...

  5. Android 使用XML隐藏ActionBar中遇错的解决的方法

    今天我在使用Menifest.xml让程序隐藏标题栏是一直出错.主要内容是: You need to use a theme.AppCompat theme(descendant) with this ...

  6. Delphi的WebBrowser改造,对网页中Alter等对话框的改造方法(通过COM来改造)

    刚有一段时间没做博客了,今天刚好有人问了这个问题,而自己以前也弄过,于是这里有了一篇新的博文. 关于改造WebBrowser控件的一些技巧,大家可以参考MSDN或者蒋晟写的一个东西,里面有讲的很详细的 ...

  7. web 开发之js---js 实现网页中播放wav的一种方法(flash播放器)

    http://blog.csdn.net/whumr1/article/details/6948160

  8. 【Web技术】401- 在 React 中使用 Shadow DOM

    本文作者:houfeng 1. Shadow DOM 是什么 Shadow DOM 是什么?我们先来打开 Chrome 的 DevTool,并在 'Settings -> Preferences ...

  9. 网页中插入外部视频的几种方法(PC与手机网页通用)

    网页中加入视频的几种方法(PC与手机网页通用) 方法一: <!doctype html> <html> <head> <meta charset=" ...

随机推荐

  1. qt 内置图标使用

    QToolButton *button = new QToolButton(this); button->resize(100,30); button->setToolButtonStyl ...

  2. 打开视图 :1449 - the user specified as a definer ('root'@'%')does not exist

    从一个数据库数据迁移到本地localhost   程序在调用到数据库的视图时报错,直接在数据库中打开视图时也报错,类似:   mysql 1449 : The user specified as a ...

  3. Spring Boot 揭秘

    SpringBoot基础 微服务 解决大一统的服务化架构的问题 代码冲突问题 交付复杂,影响面大 测试困难 微服务的好处 可扩展性 隔离性 灵活性,多语言多技术生态 微服务的挑战 保持微服务的互通性 ...

  4. struts2简单类型参数转换器(拦截器自动转换)

    这边测试类型int,string,date,list(set),map,下面贴代码 struts.xml文件代码 <!-- 类型转换 --> <action name="C ...

  5. 【shell编程】之基础知识了解shell

    一.什么是shell Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了 ...

  6. LA3641 Leonardo's Notebook

    题意 PDF 分析 给出一个26个大写字母的置换B,是否存在A^2 = B 每个置换可以看做若干个循环的乘积.我们可以把这些循环看成中UVa 10294的项链, 循环中的数就相当于项链中的珠子. A^ ...

  7. haproxy httpcheck with basic auth

    一个简单的需求,就是需要在 haproxy 的 httpcheck 使用 basic 认证,解决方法 base64 编码username 以及密码 echo -n "my_username: ...

  8. 使用rclone 进行minio 文件同步

    rclone 是一个开源的就有命令行的同步工具,主要是面向云存储的数据同步 安装 mac 系统 操作 cd && curl -O https://downloads.rclone.or ...

  9. uname command

    The command uname helps us in development special in scripts, see help of the uname uname --help Usa ...

  10. AI 学习

    极简状态机: /* 脚本名称: 脚本作者: 建立时间: 脚本功能: 版本号: */ using UnityEngine; using System.Collections; namespace Voi ...