让文字在一行上下最好的居中方法:line-height: px
return关键字2个作用:1.结束函数 2.返回一个值给调用者
给容器设定尺寸, 不给图片设置尺寸,图片显示可能比容器大
var val = t.value; 获取文本框内容
var pVal = box.innerHTML;
var ary = pVal.split(val); //字符串切割完之后的到的是数组,不包括val的数组
var str=ary.join("<span>"+val+"</span>"); //join,将数组拼接成字符串
box.innerHTML=str; //将字符串写入网页之中
text-align: center; /*只能文档(字)居中,不能让图片居中*/ 可以继承
ins[1].onfocus = function(){
spans[1].style.display = "none";
spans[1].style.background= green;
}
.red{color: red;}
<div id="box">box</div>
//给某个元素点击只能切换颜色
$("#box").addClass("red").click(function(){
// $(this).removeClass("red");
$(this).toggleClass("red"); //this指id名为box对应的标签
});
//让网页禁止选择、复制、右键
<body leftmargin=0 topmargin=0 oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>
//相关设置
oncontextmenu='return false'
ondragstart='return false'
onselectstart ='return false'
onselect='document.selection.empty()'
oncopy='document.selection.empty()'
onbeforecopy='return false'
onmouseup='document.selection.empty()'
//让网页禁止复制
<body onmousemove=/HideMenu()/ oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">
//通过JS的方式禁止复制,选择
document.oncontextmenu=new Function("event.returnValue=false");
document.onselectstart=new Function("event.returnValue=false");
//禁止页面打印(其实是打印空的)
<style>
@media print{
body{display:none}
}
</style>