jquery Development Experience Example notes

Source: Internet
Author: User

jquery Get file Select the extension of the input box

var file=$ ("Input[name= ' file ']"). Val () var filename=file.replace (/.* (\/|\\)/, ""); File name var fileext= (/[.) /.exec (filename))? /[^.]  +$/.exec (Filename.tolowercase ()): "; Extended Name

Today when using Ajaxfileupload, encountered a to refresh the page to upload again, using the Live () method to bind <input type= "File" > The Change event can be resolved? Direct $ ("xxx"). change (); Can only be called once, reportedly is the security of IE browser. Finally found a solution. IE browser <input type= "file" > choose to complete the automatic submission of the problem, after each processing is completed <input type= "file"/> replaced with the original code, and then add a different attribute. As in this example, the title is added.

    var count =-1;    $ ("#upload"). Live ("Change", function () {        count++;    $.ajaxfileupload (config);    $ ("#upload"). ReplaceWith ("<input type= ' file ' id= ' upload ' name= ' upload ' style= ' position:relative; top:0px; left:-240px; width:346px; height:46px; opacity:0; Filter:alpha (opacity=0); Cursor:pointer; Title= "+ count +" '/> ");})    

jquery calculates age, Constellation, and zodiac examples based on birthdays:


jquery Determines if there is another specified element under the element

$ (this). have ("P"). Length > 0//This code means that the number of current elements containing p, if it contains P is 1, does not contain P is 0. Because $ (this) is definitely 1, add a condition to it, containing P's $ (this) if it is 1, or 0.

Another way is to use find

$ (this). Find ("P"). Length > 0//The sentence code means that the number of P sub-elements contained is greater than 0

jquery determines whether the current element is hidden or displayed

$ (this). Is (": hidden"); Returns True if the element is hidden

is very useful, he can use the jquery selector as a parameter, especially with jquery inside the selector of those with a colon beginning with the filter, to achieve a variety of judgments. such as: ": Checked,:hidden" and so on. Give an example:

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.