1.文本上传控件的美化(鼠标放在上面显示文件名)
/*a upload */
.a-upload {
padding: 4px 10px;
height: 20px;
line-height: 20px;
position: relative;
cursor: pointer;
color: #888;
background: #fafafa;
border: 1px solid #ddd;
border-radius: 4px;
overflow: hidden;
display: inline-block;
*display: inline;
*zoom: 1
}
.a-upload input {
position: absolute;
font-size: 100px;
right: 0;
top: 0;
opacity: 0;
filter: alpha(opacity=0);
cursor: pointer
}
.a-upload:hover {
color: #444;
background: #eee;
border-color: #ccc;
text-decoration: none
}
<a href="javascript:;" class="a-upload">
<input type="file" name="" id="">点击这里上传文件
</a>
$(".a-upload").on("change","input[type='file']",function(){
var filePath=$(this).val();
if(filePath.indexOf("jpg")!=-1 || filePath.indexOf("png")!=-1){
$(".fileerrorTip1").html("").hide();
var arr=filePath.split('\\');
var fileName=arr[arr.length-1];
alert(fileName);
$(".showFileName1").html(fileName);
file = filename;
alert(file);
}else{
$(".showFileName1").html("");
$(".fileerrorTip1").html("您未上传文件,或者您上传文件类型有误!").show();
return false;
}
});
2.String中使用<br>
在html中换行
StringBuffer str = new StringBuffer();
str.addpend("^^^^^^").append("<br>").append("^^^^^^^");
$("").html(str.toString());
结果:
^^^^^^
^^^^^^^
3.td中实现滚动条
在td中添加<div></div>标签
<div style="overflow-y:scroll;height:***px;"></div>