#1882
展开↯#1883
作者:广西南宁市
Html+CSS input type=file 文件标签的美化
<!--美化Input tpye="file", 文件上传标签 -->
<input type="text" size="20" name="upfile" id="upfile" readonly style="border:1px dotted #ccc">
<input type="button" onclick="path.click()" style="width:60px; border:1px solid #ccc; background-image:url(img/sc.png); /*background-color: #b3d4fc*/">
<input type="file" id="path" style="display:none" onchange="upfile.value=this.value"> Run code
Cut to clipboard
input.onclick =btnClick
指定input元素对象的click事件处理程序为btnClick,即绑定
input.onclick()
触发input元素对象的click事件,即相当于点击这个input元素Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-15, 09:51:41
#1885
作者:广西南宁市
找点时间,找点空间,拎两井盖,回河南看看。妈妈顺来了几副碗筷,爸爸顺来了几碟咸菜!偷窃的成果和妈妈说说,盗窃的技巧和爸爸谈谈!回河南看看河南看看!哪怕去隔壁邻居顺上点钢管!爸妈不图儿女为家偷多少东西啊!一辈子只为偷的一个平平安安!
文章:街上如果看到两个姑娘向你走来,可要小心 发表时间:2017-03-14, 14:13:59
#1886
作者:广西南宁市
刚才暗恋的女老师往楼下吐痰,我跑过去一下接住了刚好吐在我嘴里,那痰香甜润滑,晶莹剔透, 我连忙伸大拇指称赞:好痰!好痰!! 老师脸一红,冲我娇媚的笑了一下。抱着手里的教科书害羞的走开了。 “老师!你的痰!” 老师再回眸一笑:“是你的痰~” 旁边的同学们投来了羡慕的眼神,而我则高高的昂起了头,大步向教室走去,深藏功与名。。。 走进教室,还在品味这口痰,里面有一股淡淡的芳香,甜而不腻,腻而不肥,“咕噜”一声,我贪婪把它吞下。
文章:街上如果看到两个姑娘向你走来,可要小心 发表时间:2017-03-14, 14:11:10
#1889
作者:广西南宁市
js实现点击一次图片旋转90度,再点击再转90度
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
window.onload = function(){
var current = 0;
document.getElementById('target').onclick = function(){
current = (current+90)%360;
this.style.transform = 'rotate('+current+'deg)';
}
};
</script>
</head>
<body>
<img id ="target" src="1.jpg" alt="">
</body>
</html>Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-13, 12:17:33
#1890
作者:广西南宁市
js实现点击一次图片旋转90度,再点击再转90度
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
window.onload = function(){
var current = 0;
document.getElementById('target').onclick = function(){
current = (current+90)%360;
this.style.transform = 'rotate('+current+'deg)';
}
};
</script>
</head>
<body>
<img id ="target" src="1.jpg" alt="">
</body>
</html>Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-13, 12:17:33
#1891
作者:广西南宁市
一个div进行旋转或缩放后,获取它变形后的宽高
var test = document.querySelector('#test');
var rect = test.getBoundingClientRect();
alert('width:' + rect.width + 'height:' + rect.height);Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-13, 12:16:09
#1892
作者:广西南宁市
图片点击一次旋转90度变形旋转顺时针
window.onload = function(){
var current = 0;
$("img").click(function(){
$('.easyzoom').css('height','');
$('.easyzoom img').css('margin-top','');
$('.easyzoom img').css('transform','rotate(0deg)');
current = (current+90)%360;
$(this).css('cursor','se-resize');
var rect = this.getBoundingClientRect();
/*alert('width:' + rect.width + 'height:' + rect.height);*/
$(this).parent().css('height',rect.width+'px');
if($(this).width()>$(this).height()){
$(this).css('margin-top',(($(this).width()-$(this).height())/2)+'px');
if(rect.height>rect.width) $(this).css('margin-top','');
}else{
$(this).css('margin-top',(($(this).width()-$(this).height())/2)+'px');
if(rect.height<rect.width) $(this).css('margin-top','');
}
if(current==0 || current==180){
$(this).parent().css('height','');
$(this).css('margin-top','');
}
$(this).css('transform','rotate('+current+'deg)');
});
};Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-13, 12:15:14
#1896
作者:广西南宁市
<html>
<head>
<title></title>
</head>
<body>
<div>
<span>请选择风格(默认风格一)</span>
<select id='sel'>
<option value='true' selected="true">风格一</option>
<option value='false'>风格二</option>
</select>
</div>
<div>
<textarea id='text' style='width:400px;height:300px;'></textarea>
</div>
<script type='text/javascript'>
document.getElementById('text').onkeyup = function(e){
var is = document.getElementById('sel').value == 'true';
if (event.keyCode == 13){
if (is){
if (event.ctrlKey){
this.value += '\n';
}else{
alert('发送信息...');
this.value='';
}
}
else if (event.ctrlKey){
alert('发送信息...');
this.value='';
}
}
};
</script>
</body>
</html>
Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-10, 15:50:15
#1897
作者:广西南宁市
<script>
var down = false;
function fun(isDown, e){
//释放按下ctrl记录,并终止执行
if(!isDown){
down = false;
return false;
}
e = e || window.event;
//ctrl(17)
if(e.keyCode == 17){
//当ctrl按下时记录
down = true;
}
//enter(13)
if(e.keyCode == 13){
//当enter按下时判断ctrl是否是按下状态
if(down){
/*
发送消息操作,你自己写这块吧,用ajax或表单都行
*/
alert("发送消息...");
}
}
}
</script>
<form action="" method="post">
内容:<textarea name="content" onkeydown="fun(true, event)" onkeyup="fun(false, event)"></textarea>
</form>Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-10, 15:49:52
#1898
作者:广西南宁市
这个就是在ie中叫
altKey ctrlKey shiftKey
在非ie中叫
metaKeyRun code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-10, 15:49:00
#1899
作者:广西南宁市
js实现按Ctrl+Enter发送效果
function keySend(event) {
if (event.ctrlKey && event.keyCode == 13) {
sbFrm();
}
}Run code
Cut to clipboard
文章:常用html、demo代码 发表时间:2017-03-10, 15:47:51
单引号转义一下,避开引号冲突就好了: <a onclick='$("iframe[name=\'mainFrame\']")[0].contentWindow.imgDblclick(0);'></a> onclick=‘function(){ js语句}’ <a onclick='javascript: $("iframe[name='mainFrame']")[0].contentWindow.imgDblclick(0);'></a> <div id="top" onclick="if(center.style.display=='none'){center.style.display='block'}else{center.style.display='none'}"> <a href="#" onclick="return pa();" >测试</a>