Show toolbar

2017年11月23日 星期四

Click the upload icon below to upload a file

標題:Click the upload icon below to upload a file
JavaScript (index.html):
<div>
    <label for="fileboxy">
        <img src="http://bit.ly/2PmisVq" style="cursor: pointer;" />
    </label>
    <input id="fileboxy" type="file" style="display: none;" />
</div>

範例:

說明:
使用label的方式點選圖片同步觸發隱藏的input file選擇檔案。

2017年4月18日 星期二

Random Color

標題:Random Color
JavaScript (index.html):
<button onclick="getRandomColor(this)">Change Color</button>
<script>
function getRandomColor(e) {
  var color = '#' + Math.floor(Math.random()*16777215).toString(16);
  console.log(color);
  e.innerHTML = color;
  e.style.color = color;
}
</script>

範例:


說明:
透過『16777215』白色,隨機產生顏色。