手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >修改file按钮的默认样式实现代码
修改file按钮的默认样式实现代码
摘要:复制代码代码如下:添加附件functionfclick(obj){style.posTop=event.srcElement.offsetT...

复制代码 代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<html>

<head>

<title>添加附件</title>

</head>

<script type="text/javascript" src="jquery-1.8.0.js"></script>

<script type="text/javascript">

function fclick(obj){

style.posTop=event.srcElement.offsetTop

style.posLeft=event.x-offsetWidth/2

}

$(function(){

$("#addFile").click(function(){

var br = $("<br>");

var input1 = $("<input id='inputrecievedocument' type='text'/>");

var input2 = $("<input type='button' id='btnrecievedocument' onmouseover='fclick(t_file)' value='浏览'/>");

var input3 = $("<input name='upfile' type='file' id='t_file' onchange='inputrecievedocument.value=this.value' hidefocus/>");

var button = $("<input type='button' value='删除'/>");

$("#file").append(br).append(input1).append(input3).append(input2).append(button);

button.click(function() {

br.remove();

input1.remove();

input2.remove();

input3.remove();

button.remove();

});

});

});

</script>

<body>

<form method="post" action="" enctype="multipart/form-data">

<input type="button" value="添加附件" id="addFile"/>

<div id="file"></div>

</form>

</body>

</html>

IE9中运行如下:

1

【修改file按钮的默认样式实现代码】相关文章:

精确到分钟的js日历控件,日期选择器代码

JQuery使用index方法获取Jquery对象数组下标的方法

javascript为按钮注册回车事件(设置默认按钮)的方法

一段实时更新的时间代码

菜单制作学习一个小东西 原创

将HTML自动转为JS代码

使用RequireJS优化JavaScript引用代码的方法

Javascript 字符串模板的简单实现

些很实用且必用的小脚本代码

判断file框选择的是否为图片

精品推荐
分类导航