我是靠谱客的博主 潇洒面包,这篇文章主要介绍每日一剂:怎么间接调用input type="file"和type="date",现在分享给大家,希望可以做个参考。

在手机端上,经常会使用到<input type=file accept="image/*" />这个调用手机上的系统相册和拍照摄像头。但是这个样式很难看,怎么自定义div或者button来调用这个input呢?

html:

<button id="btn" style="margin: 25px;">点击选择图片</button>
<input type="file" accept="image/*" id="image"/>

js:

$("#btn").click(function(){
return $("#image").click()
})


如何调用type="date"的input呢?

html:

<button id="btn" style="margin: 25px;">点击选择图片</button>

<input type="date" id="date" />

js:

$("#btn").click(function(){
return $("#date").focus();

});




最后一种最简单的调用.div内包input,把input的宽度和高度充满div,就能直接调用,不用写js

html:

<div style="width: 100px;height: 100px;background: #03A9F4;">

<input type="file" style="width: 100px;height: 100px;opacity: 0;"/>
</div>



最后

以上就是潇洒面包最近收集整理的关于每日一剂:怎么间接调用input type="file"和type="date"的全部内容,更多相关每日一剂:怎么间接调用input内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部