Question about JS cannot set input value

Source: Internet
Author: User
Tags script tag

HTML content from:

<type= "text/html"  ID= "thetemplate">     <id= "input_id"  type= "text"/>  Initialize HTML content in this script tag </script>

After the page is loaded, take out the HTML contents of the script tag and append into the body, then execute the following code

var numelem    = document.getElementById (' input_id ');   Here is the DOM element node that can find input, but it may not be the same as the normal DOM element node        numelem.value = "AA";   Here you will find that no matter how you set it the value will not change on the page        console.log (numelem.value);  What's even more strange is that you'll find that the output "AA" is the value you set in the previous step, but it doesn't show up on the page.

Using the Chrome browser to do the test, other browsers have not tried, this weird phenomenon should be because the HTML content is caused by the script tag export, do not know the browser is not counted as a bug

Question about JS cannot set input value

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.