How does JavaScript get and set the height and width of the div and are compatible with any browser? Look at the code:
Copy Code code as follows:
Gets the width height of the div1:
Copy Code code as follows:
Alert (document.getElementById ("Div1"). offsetheight); Compatible FF, IE, etc.
Alert (document.getElementById ("Div1"). offsetwidth); Compatible FF, IE, etc.
JavaScript implementation Show and hide Div method totals
Let's take a look at how other small partners are going to do it.
Example three:
Let's take a look at one of the simplest examples, which implements the display and hidden layers
Below is the closed layer, in fact, the principle is the same just add a effect.
A special customer requirement: to display data in a table on a page, the data volume is not large. If you do not want to use the browser's scroll bar, you can only scroll The data in the table in the Div, however, a special requirement is that the scroll bar must be automatically rolled to the bottom. Query related information,... SyntaxHighlighter. all ();
A special customer requirement: to display data in a table on a page, the data volume is not l
Online many Ajax jquery upload images to use the Submit button, how to upload and see directly on this page when users click on the div? Life and death problems, more Mr. Chia.
click me to pass the photo to upload.php
Reply content:
Online many Ajax jquery upload images to use the Submit button, how to upload and see directly on this page when users click on the div? Life a
The code found on the Internet has been modified,Fixed the issue where custom colors could not be defined, corrected IE8 errors, and other bugs were compatible with IE6 ~ 8. FirefoxCustomizable// The title height of the prompt window// The border color of the prompt window// The title Color of the prompt window// The title background color of the prompt window// The background color of the prompt content// Prompt text alignmentFunction to bring up a large DI
The project encountered the need to cross-frame display div problem, Baidu a bit, collected a bit of wisdom of the masses, special sorting out the following example, first look at:In this case there are 4 pages:Index.htmlFrame.htmlFrame-top.htmlFrame-main.htmlI ' m main frameThe page is set up, directly open index.html can see the effect. The specific principle is to display the div of the parent page from
HTML>lang="en">charset="UTF-8">Click to turn div into redid="Div">Click to turn div into redJavaScript little Exercise-click to turn div red (traverse through for Loop)
QQ space is often a friend of the personality of QQ space editing module impressed, you can drag the elements on the page and adjust the size of the dynamic layout, of course, every time I csdn blog will also be in the lower right corner to see a news window, this effect is really cool, then we also come to achieve a bar.
implementation Steps:
1. The first is to dynamically create an HTML structure like this:
Copy Code code as follows:
2.id for the body for you to place t
Article Introduction: Click on the button to change the Div property, by clicking on a different button to set the div style.
Click on the button to change the Div property, by clicking on a different button to set the div style.The code is as follows:
A special customer requirement: to display data in a table on a page, the data volume is not large. If you do not want to use the browser's scroll bar, you can only scroll The data in the table in the div, however, a special requirement is that the scroll bar must be automatically rolled to the bottom.
After querying the relevant information, div does not have the auto-scroll attribute and can only simula
After querying the relevant information, Div does not have the auto-scroll attribute and can only simulate mouse scrolling to achieve the desired effect.
The key part is here: div. scrollTop = div. scrollHeight;
The following is the simplified code:Copy codeThe Code is as follows:
In fact, the implementation is very simple, but generally there is little such de
JS How to add a button, a row of data (including the title, author, time, etc.) all added to another Div, and can also position style and another page list sorting style uniform, is similar, click to add to the second diagram
Reply content:
JS How to add a button, a row of data (including the title, author, time, etc.) all added to another Div, and can also position style and another page list sorting
For details about how to always display the Div in the middle of the screen, refer.
1. display in the middle. (See: sky100articles1790515)
The Code is as follows:
. OrdersearchDivCss{Position: absolute;Z-index: 100;Display: block;Background-color: # 6ec1df;}
Js code
Call:
// Functions of the object obtained by element id in the JScript File
Function $ (id)
{
Return document. getElementById (id );
}
The Code is as follows:
Function sc1 (Div
Use native js and jQuery to change and reset div attributes at will. In the input box, enter "attribute name" and "attribute value", and click "OK" to view the effect, if you are interested, do not miss out on some simple examples. use native js and jQuery to change the p attribute and reset it at will. The Code is as follows:
The Code is as follows:
Function parameters to change the value of any Div
This article mainly introduces how to obtain div coordinates using js. It is very simple and practical to call the jQuery plug-in to obtain div element coordinates, for more information about how to obtain pcoordinates in js, see the example in this article. We will share this with you for your reference. The details are as follows:
The most commonly used control in html is p. How can I obtain the coordina
Using Native js and jQuery to change the name and value of the style property of the div at will, this example is more practical. New friends can look at some simple examples, use native js and jQuery to change the p attribute and reset it at will. The Code is as follows:
Function parameters to change the value of any Div attribute
Use RadioButten (or CheckBox) to display and hide the div. When "female" is selected, "beauty and talent" are displayed. When "male" is selected, the div is hidden as follows, if you are interested, refer to "female" and show "beauty and talent". When "male" is selected, hide the content on the aspx page:
The Code is as follows:
Use RadioButten (or CheckBox) to display and hide p
This article describes how to obtain the error Cause Analysis and solutions for the internal content of the div. For more information, see section 1. Error description.
2. Error cause
Because an element is added to p, append () is used ();
$ ("# PStyle"). append ("_ Data [I]. name");
The append contains dynamic data. When the request data is empty, obtain and judge the content in p:
Var pContent = $ ("# pStyle" ).html (); if (pContent =
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.