How to stack automatically generated js elements and original page elements. js automatically generates

Source: Internet
Author: User

How to stack automatically generated js elements and original page elements. js automatically generates

Product attributes and product specifications are the elements dynamically generated by js. The two text boxes of product extension information are original elements, which are stacked, I thought it was because the size of the div where the generated element is located is not fixed, because the check boxes below the product specification are generated by the second ajax, I doubt whether ajax cannot push the original elements of the page down to a proper position for the second time.

After several hours, I tried to fix the size of the div in the container where the element is located, but it is not fixed. The number of elements is not fixed. I tried to change the order of generating attributes and specifications, the property part is piled up to the specification part. Why are the elements of the Specification Part not independent of each other? Later I thought it would be a floating, removing the floating, and giving the original elements (product expansion information part) with clear: both;, it is normal.

Don't be alarmed when encountering problems, don't be afraid of troubles, and handle them slowly.


Js traverses all elements on the current page and obtains the elements with the title attribute.

Function getHasTitles (parentNode) {var allNodes = parentNode. getElementsByTagName ('*'); var length = allNodes. length; var I; var hasTitles = []; var node; for (I = 0; I <length; I ++) {node = allNodes [I]; if (node. title) {hasTitles. push (node) ;}} return hasTitles;} var hasTitles = getHasTitles (document );
Jquery gets all elements
$ ("*")


How to obtain page elements in JS

Well, the upstairs is correct. In this way, an error is prompted in the advanced HTML editor. Because it does not conform to the standard, the ID name must be unique.
We recommend that you:
<Div id = "menu1">
<Div class = "menu"> </div>
</Div>
<Div id = "menu2">
<Div class = "menu"> </div>
</Div>
GetElementById ("menu1"). childNodes [0]. inerText = "content"

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.