
Input type file styling
Input type file styling
We’ll attempt to use programming in this lesson to solve the "Input type file styling" puzzle.
You can change the styling of your default input type file button with an attractive button design. You can make it attractive using CSS style and also you can hide and trigger it using another button on click event.-
Make input type file element invisible, add button and on click button trigger click event on input file
<form method="post"> <button class="btn btn-success pull-right" onclick="document.getElementById('file').click(); return false;">Upload photo</button> <input type="file" name="image" class="image invisible" id="file" accept="image/*"> </form>
You can use bootstrap CDN which makes the input file invisible (hidden) with class invisible. You can also make the input type file invisible using visibility: hidden; with inline CSS.
Bootstrap CDN
<!-- CDN link -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Javascript
- Execute function with condition in javascript
- Short-circuits conditionals
- Animating numbers counting Javascript
- Multidimensional array example javascript
- How to check file is an image in javascript using filename
- How to Set data to localstorage in javascript
- Hide div on click outside of element in javascript/jQuery
- How to remove duplicate values from array in javascript
- Uncaught TypeError: Illegal invocation
- How to pass array as arguments to function in javascript
- How to fixed bootstrap navbar at top on scroll
- Uncaught TypeError: Cannot read property 'addEventListener' of undefined
- How to get data from localstorage in javascript
- Concat variable with string in javascript
- Json stringify
- How to make entire Div clickable in javascript
- How to open modal after redirect
- Remove hostname from URL in javascript
- Copy one array to another in javascript
- Uncaught SyntaxError: Identifier 'CODE' has already been declared
- Remove property from object in javascript
- How to add a property to object with condition in javascript
- How to show and hide placeholder text
- How to get query string value in javascript
- ReferenceError: $ is not defined