How to change the "Browse" button style of the file type

Source: Internet
Author: User

Original article: http://www.cftea.com/c/2009/10/22Y1CTEYZTR7S5S3.asp

In the current webpage, the input file type input box with the type of file is often encountered. I thought I tried to use CSS to modify the button style, and even the style of the input box was changed, now, how can we solve this problem? It has been a while to learn about JS controls. Now, let's try to use a hidden method to achieve this effect. The interface is displayed on one hand, actually, the Browse click event is called to change the style.

As a function, it simulates the click of a "file" type button and takes the value from the "file" type input box, at the same time, make the "file" type input box as implicit, which is what you want:

<Script language = 'javascript '>
Function AA (){
Document. All. t1.click ();
Document. All. t2.value = Document. All. t1.value
}
</SCRIPT>

Place the following on the pageCode:

<Input id = 'T1 'Type = 'file' style = "display: none"> <p>
<Input type = text size = 25 name = t2 style = "height: 18px">
<Input type = button value = browse style = "font-size: 12px; Height: 19; Background: # FFFF00" onclick = "Blur (); AA ()">

Run code

<textarea class="code_run" rows="10" cols="60"><Script language = 'javascript '> <br/> function AA () {<br/> document. all. t1.click (); <br/> document. all. t2.value = document. all. t1.value <br/>}< br/> </SCRIPT> <br/> <input id = 't1' type = 'file' style = "display: none "> <p> <br/> <input type = text size = 25 name = t2 style =" height: 18px "> <br/> <input type = button value = browse style =" font-size: 12px; Height: 19; Background: # FFFF00 "onclick =" Blur (); AA () "></textarea>
[Ctrl + A select all tips: you can modify some code and then press run]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.