question: What does jquery's dollar sign $ do?
Answer: Actually the dollar sign $ is just the "jquery" Alias, it is the jquery selector, the following code:
- $ (document). Ready (function () {
- });
Of course you can also use jquery instead of $, the following code:
- JQuery (document). Ready (function () {
- });
jquery is the use of this dollar symbol to achieve a variety of flexible DOM element selection, such as $ ("#main") is the ID of the element is selected.
Question: What is the difference between the onload () function in the body and Document.ready () in jquery?
Answer: The difference between onload () and Document.ready () has the following two points:
1. We can use multiple document.ready () in the page, but only one time, onload ().
2. The Document.ready () function is called after the page DOM element has been loaded, and the onload () function is called after all associated resources (including images, audio) have been loaded.
Question: What kinds of selectors are there in jquery?
Answer: From my own point of view, there can be 3 types of selectors, as follows:
1. Basic selector: Returns the matching DOM element directly from the ID, CSS class name, and element name.
2, hierarchical selector: Also known as the path selector, you can select the corresponding DOM element according to the path hierarchy.
3. Filter selector: Filter the relevant conditions on the previous basis to get the matching DOM elements.
Question: Use jquery to set all the element borders on the page to a 2px wide dashed line?
Answer: This is the time for the jquery selector to play, the code is as follows:
- <script language="javascript" type="Text/javascript">
- $ ("*"). CSS ("Border", "2px dotted Red");
- </Script>
question: How do I use jquery to implement a click button to pop up a dialog box?
Answer: The code is as follows:
- <input id= "Inputfield" type=" text " size=" />
-
- JQUERY:&NBSP;&NBSP;
- << Span class= "Tag-name" >script type= "Text/javascript" span class= "tag" >> $ (document). Ready (function () { $ (' #Button1 '). Click (function () { alert ($ (' #inputField '). attr ("value")); }); }); </ script>
Question: How do I disable the browser's forward back button with jquery?
Answer: The implementation code is as follows:
- <script type="Text/javascript" language="javascript">
- $ (document). Ready (function () {
- Window.history.forward (1);
- OR
- Window.history.forward (-1);
- });
- </Script>
A few small questions about jquery