Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:00:40+00:00 2026-06-01T23:00:40+00:00

Having trouble with a function hitting the page as soon as possible, so i

  • 0

Having trouble with a function hitting the page as soon as possible, so i need to write it in pure javascript and include it in the head. not sure how to go about it, because as i understand it, by using .replace() the new element will be moved to a different location on the page. jQuery’s replaceWith() behavior is ideal.

$("#imagefiles").replaceWith("<input type='file' name='imagefiles' id='imagefiles' />");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:00:42+00:00Added an answer on June 1, 2026 at 11:00 pm
    var image = document.getElementById('imagefiles'), parent = image.parentNode,
    tempDiv = document.createElement('div');
    
    tempDiv.innerHTML = "<input type='file' name='imagefiles' id='imagefiles' />"
    
    var input = tempDiv.childNodes[0];
    
    parent.replaceChild(input, image);
    

    DEMO


    EDIT as per am not i am:

    var image = document.getElementById('imagefiles'), parent = image.parentNode,
    input = document.createElement('input');
    input.id = input.name = "imagefiles";
    input.type = 'file';
    
    parent.replaceChild(input, image);
    

    edited DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble with the binary_search function listed at the top. not sure where to
I am having trouble using a javascript function in my wp7 application. I am
I'm having trouble using python function decorators in Google's AppEngine. I'm not that familiar
I'm having trouble with a javascript function that needs to take a global variable
I'm converting some javascript to coffeescript, and I'm having trouble accessing a function I've
I'm having trouble replacing a function from a different module with another function and
I'm having trouble creating a mouseover function with an NSTableView. The idea is that
I'm having trouble creating a global function accessible from within all classes. I receive
I'm having trouble with the MyClass::function(); style of calling methods and can't figure out
I'm having trouble with something that I understand should function out of the box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.