div

Hide particular div onload and then show div after click

匿名 (未验证) 提交于 2019-12-03 00:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two divs div1 and div2 . I want div2 to be automatically hidden but when i click on preview div then div2 to be made visible and div1 to hide. This is the code i tried but no luck :( This is preview Div1. This is preview Div1. This is preview Div2 to show after div 1 hides. PREVIEW 回答1: Make sure to watch your selectors. You appear to have forgotten the # for div2 . Additionally, you can toggle the visibility of many elements at once with .toggle() : // Short-form of `document.ready` $(function(){ $("#div2").hide(); $("#preview").on(

How to align an absolute div

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following code: body{ margin: 10px; } .menu { border: solid black; border-width: 1px 1px 0px 1px; background-color: black; color: white; width: 300px; position: relative; padding: 12px; } .menu:hover{ background-color: white; color: black; } .dropdown { position: absolute; background-color: white; width: 200px; left: -1px; border: solid black; border-width: 0px 1px 1px 1px; color:black; top:100%; } .dropdown ul { list-style: none; padding: 10px; margin: 0; } .zoom { zoom: 200%; } <div class="menu zoom"> Click me <div class=

利用div显示隐藏实现的分页效果

匿名 (未验证) 提交于 2019-12-03 00:40:02
实现步骤: 1、创建对应切换div < div class ="bottom_daohang" > < div class ="bottom_daohang_zong" > < div class ="bottom_daohang_left value_left ace" > < </ div > < div id ="bianse1" class ="bottom_daohang_number ace red value_number" bs ="1" > 1 </ div > < div id ="bianse2" class ="bottom_daohang_number ace value_number" bs ="2" > 2 </ div > < div id ="bianse3" class ="bottom_daohang_number ace value_number" bs ="3" > 3 </ div > < div id ="bianse4" class ="bottom_daohang_number ace value_number" bs ="4" > 4 </ div > < div id ="bianse5" class ="bottom_daohang_number ace value_number" bs ="5" > 5 </ div > <

如何实现div盒子水平垂直居中

匿名 (未验证) 提交于 2019-12-03 00:38:01
关于如何使一个小盒子在大盒子中水平垂直居中有很多方法,下面将列举常用的几种: < div class = "parent" > < div class = "child" >DEMO</ div > </ div > .parent { width : 200 px ; height : 300 px ; background : #ddd ; } .child { background : #666 ; color : #fff ; } 设置margin自动适应,然后设置定位的上下左右都为0,就如四边均衡受力从而实现盒子的居中; .parent { position : relative ; } .child { position : absolute ; margin : auto ; top : 0 ; left : 0 ; right : 0 ; bottom : 0 ; } 使用子绝父相的定位方式,无须知道盒子自身的高度,使用范围较广 .parent { position : relative ; } .child { position : absolute ; left : 50 % ; /* 父盒子宽度的50% */ top : 50 % ; /* 父盒子高度的50% */ transform : translate(- 50 %,- 50 %) ; /*

div

匿名 (未验证) 提交于 2019-12-03 00:32:02
<!DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < title > Title </ title > < style > /*.c1{*/ /*height: 100px ;*/ /*width:100px;*/ /*border:1px red solid;*/ /*text-align:center;*/ /*line-height:100px*/ /*}*/ /*.c2:hover{*/ /**/ /*}*/ #id1{ width : 20px ; height : 20px ; border : solid red 1px ; background - image : url ( ‘ http : //ui.imdsx.cn/static/image/icon.png‘); background - repeat : no - repeat ; background - position : 0 0 } </ style > </ head > < body style = " margin : 0 auto " > <!--<div style=" height: 100px ; width: 100px;"></div>--> <!--<div style=

关于js中获取div中的数据

匿名 (未验证) 提交于 2019-12-03 00:26:01
原文地址为: 关于js中获取div中的数据 关于从中学到的知识: 上面的标签在这几钟基于两种浏览器的内核的浏览器,这几种方法是不兼容的。下面是解决方案 兼容火狐ie的js 获取div的内容 else var text = document.getElementById(“text”).textContent; 用来获取浏览器的名称,第一句话的意思就是当获取到的浏览器的名称中带有Explorer。 涉及到indexof用法 indexOf 方法返回一个整数值,指出 String 对象内子字符串的开始位置。如果没有找到子字符串,则返回 -1。 转载请注明本文地址: 关于js中获取div中的数据 文章来源: 关于js中获取div中的数据

可编辑div的一些方法总结(一)复制文字去除标签和样式

匿名 (未验证) 提交于 2019-12-03 00:21:02
// 去除复制样式的方法 function textInit(e) { e.preventDefault(); // 阻止默认事件 var text; var clp = (e.originalEvent || e).clipboardData; if (clp === undefined || clp === null ) { text = window .clipboardData.getData( "text" ) || "" ; if (text !== "" ) { if ( window .getSelection) { var newNode = document .createElement( "span" ); newNode.innerHTML = text; window .getSelection().getRangeAt( 0 ).insertNode(newNode); } else { document .selection.createRange().pasteHTML(text); } } } else { text = clp.getData( 'text/plain' ) || "" ; if (text !== "" ) { document .execCommand( 'insertText' , false , text); } } }

如何获取div中自定义“ data-*/data_* ”中的值

匿名 (未验证) 提交于 2019-12-03 00:18:01
HTML <div id="one" data-test="123"></div> <div id="tow" data_test="456"></div> jQuery 第一种: var gain = $("#one").data("test"); console.log(gain); // 123 注:data_*格式的,第一种方式获取不到! 第二种: var gain = $("#one").data("data-test"); var gain2 = $("#tow").data("data_test"); console.log(gain); // 123 console.log(gain2); // 456 文章来源: 如何获取div中自定义“ data-*/data_* ”中的值

点击div以外的页面隐藏该div

匿名 (未验证) 提交于 2019-12-03 00:18:01
思路:在触发DOM上的某个事件的时候会产生一个事件对象event,这个对象包含着所有与事件有关的信息,包括产生事件的元素、事件类型等相关信息,思路一中div的click事件处理程序传入的参数就是这个event对象。访问IE中的event对象有几种不同的方式,取决于指定事件处理程序的方法。直接为DOM元素添加事件处理程序时,event对象作为window对象的一个属性存在。 <script type="text/javascript"> $(document).bind('click',function(e){ var e = e || window.event; //浏览器兼容性 var elem = e.target || e.srcElement; while (elem) { //循环判断至跟节点,防止点击的是div的id=‘test’的子元素 if (elem.id && elem.id=='test') { return; } elem = elem.parentNode; } $('#test').css('display','none'); //点击的不是div或其子元素 }); </script> 文章来源: 点击div以外的页面隐藏该div