Jquery Experience 1. jquery experience

Source: Internet
Author: User

Jquery Experience 1. jquery experience

1. How to refresh the page with Javascript:
Location. reload () // refresh
Location = location
Location. assign (location)
Document.exe cCommand ('refresh ')
Window. navigate (location)
Location. replace (location)
Document. URL = location. href
JQuery has not found any way to refresh the page.
2. jquery dynamically controls the display and hiding of div
Answer: $ ("# divObj"). hide (); // hide
$ ("# DivObj"). show (); // display
3. dynamically operate the href attribute of tag
$ ("# Zj "). attr ("href", "javascript: alert ('You do not have this authorization');"); 4. the onclick Method for dynamically operating the tag $ ("# SC "). attr ("onclick", ""); 5. various events that trigger input $ ("# input "). click (); $ ('input '). trigger ('click') $ ("# sheng "). trigger ("change"); 6. jQuery gets the selected select value jQuery ("# select1 option: selected "). text (); 7. how to obtain the radio value through Jquery to obtain the single-worker value of the old Jquery version

Var_name = $ ("input [@ name = 'Radio _ name']: checked"). val ();
Versions later than Jquery 1.3
Var_name = $ ("input [name = 'Radio _ name']: checked"). val ();

The difference is that the old version has @. 8. If the select attribute is not changed, change the select value $ ("# salary option: eq (0 )"). prop ("selected ", True); 9. in the new window, open the following: target = "_ blank" 10. jsTrim $. trim (); 11. jquery changes the action attribute of the form, and changes the action of the form. Answer: $ ("# form "). attr ("action", "$ {pageContext. request. contextPath}/users/updateIntegral "); 12. when the image fails to be loaded, other images are analyzed and the following code is found on the webpage:

Analysis: pay special attention to onerror. When the image does not exist, onerror is triggered, while onerror specifies a NoPic.gif image for img. That is to say, if an image exists, pic.gif is displayed. If the image does not exist, noPic.gif is displayed. However, the problem arises. If noPic.gif does not exist, the onerror will be triggered again, resulting in a loop.
NOTE: If an image exists but the network is not smooth, an onerror may also be triggered.
Solution:
First, remove the onerror code, change the onerror code to another, or make sure that the image in the onerror is small enough and exists.
Second:
<Script type = "text/javascript">
<! -
/* Default image display */
Function nofind (event ){
Var img1_event.tar get | window. event. srcElement; // velvet IE/Chrome
Img. src = "$ {pageContext. request. contextPath}/images/ph1_03.png ";
Img. onerror = null; // do not keep beating
}
//->
</Script>
<Td align = "center">
Pai.gif "onerror =" nofind (event); "/>$ {file. name} </td> 13. monitoring carriage return event/* Monitoring carriage return event */$ (window ). keyup ( Function(E ){ If(E. keyCode = 13) {testSub ();};});

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.