Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / JavaScript - get element that was created by css

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Jan 2015 04:11
Trying to make a custom file upload button. Turns out, it's not as simple to change the look as you'd think with most input tags. So I've found this solution using the before selector. However, as this current method does not display the name of the selected file, I need a way to do that.




Here's the html code:



And what I have so far for the js function, which so far only gets the name of the selected file.



I haven't quite figured out how I can select that pseudo-element so I can update it's content to display the file name. Since it has no name or ID. Any suggestions?


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 6th Feb 2015 05:57 Edited at: 6th Feb 2015 06:06
Do you have to use raw javascript?

jQuery or Angular would make this much simpler.

Here is a quick jQuery sample that will give you a custom submit button (attached)

the button is just a div, so you can style it however you want and it will appear the same cross browser.

That said, Angular or Ember are generally better / more modern frameworks to go with, but they will be more complicated to set up, at least at first.

Attachments

Login to view attachments
Alex Deef
10
Years of Service
User Offline
Joined: 8th Apr 2014
Location: eastern europe
Posted: 22nd Feb 2015 19:21
These days, doing this kind of stuff without a library is madness. However, I assume you want to learn how this stuff works. I would suggest you look into the source of jQuery or one of the other javascript libraries.

With that in mind, the selector function has to include a lot of if/else/else if or switch case statements in order to handle all the different selectors. Example:



http://www.acheterpriligyenligne.com/
http://www.achetermed.fr/

Login to post a reply

Server time is: 2024-04-26 06:58:37
Your offset time is: 2024-04-26 06:58:37