Home > Web Front-end > JS Tutorial > jquery newbies learn how to solve common problems_jquery

jquery newbies learn how to solve common problems_jquery

WBOY
Release: 2016-05-16 18:29:18
Original
1180 people have browsed it

Q0, a must-read tutorial for beginners:

The first step, jQuery Chinese introductory guide, translation and examples, the starting point tutorial of jQuery
The second step, download the manual for easy inquiry (jQuery 1.41 Chinese API Document chm version )
The third step is to deeply understand the difference between jQuery objects and ordinary DOM objects. See Q1 for mutual conversion.
Q1, js writing method: document.getElementById('save').disabled=true;
In jquery, I write it like this $("#save").disabled = true; Why doesn’t it work?

A, this is a typical problem, in fact, because what comes out of $("#save") is actually a jQuery object, not an ordinary DOM object
This is a newbie Frequently Asked Questions.
There are 2 solutions:
1. Use JQ writing method, $("#save").attr("disabled","true");
2. Convert it to DOM writing method $("#save ")[0].disabled=true;
Of course, $("#save")[0] can also be written as $("#save").get(0). What it returns is also the DOM element

$("#save"). What eq(0) gets is still the jq object
$(dom object), you can get a jq object.

Q2, get the selected checkbox
A:
Get all selected checkboxes:
$("input:checkbox:checked" )
Judge whether a group of checkboxes are selected:
if($("input:checkbox:checked").length){}
Judge whether a certain checkbox is selected
if($( "input:checkbox").is(":checked")){}


Q3, there are symbols like [] or . in my id, what should I do? ? Or what should I do if the xml tag with namespace has:?
A: Used to escape such as


$("#id\[1\]")

Q4, in the frame page, how to operate the object of the parent window
A , the method of quoting UPC

I didn’t find a good method
I had to use the combination of DOM method and jquery method to achieve it

1. Select all the items in the IFRAME in the parent window Radio button
$(window.frames["iframe1"].document).find("input[type='radio']").attr("checked","true");

2. Select all radio buttons in the parent window in IFRAME
$(window.parent.document).find("input[type='radio']").attr("checked","true ");

iframe framework:

If the test passes in IE7, go back and try it yourself

The implementation principle is actually very simple, just use it $(DOM object) can be converted into jquery object
======================================== =============

But my method is
window.parent.jQuery("input[name=validate]").val("" );
This paragraph is from my blog to automatically fill in the verification code. If you are interested, you can analyze the framework in my FOOTER.
In fact, it is essentially the same method as UPC. You can refer to

Q5, parsing XML loaded by AJAX, and related garbled problems
A: See the previous post: hhttp://bbs.jquery.org.cn/read.php?tid-1673.html

Q6, I ​​downloaded a plug-in Interface, what happened? Doesn't it work at all in the latest jQuery?
A: Interface has been completely rewritten and renamed jQuery UI. The latest version can be found here:
http://ui.jquery.com/

Q7, the animation will flicker under IE and the effect is not ideal
A, just add the DTD definition
For example,

Q8, why does the official say
Download jQuery 1.2.3 (15kb , Minified and Gzipped), but I downloaded
jquery-1.2.3.min.js 52.8 KB
A, obviously, he used Gzip (a server-side compression technology, owned by GOOGLE). It’s not that the official website is written incorrectly and has not been updated or is a lie~

Q9, what is the difference between the three versions of pack, min and the original version?
pack is used when gzip is not enabled on the server.
min is used when gzip is enabled on the server.
The original version can be used for daily development, or for analyzing the source code yourself.

Q10, what compression software does jQuery use?
A: Packer written by Dean Edwards has now been compressed using TBCompressor(YUI Compressor). It is recommended to download a copy.
Q11,$('a[@href^="mailto"]') This code cannot be used in jQuery 1.3, but it can be used in 1.2. Why?
A: After jQuery 1.3, you no longer need to use the @ symbol. You only need to simply remove the @ symbol and it will operate normally.

Q12, can jQuery cross domain?
A: jQuery itself is an encapsulation of JS. The browser has permission settings for JS. What JS cannot do, jQuery cannot do either. But it can be cross-domain via jsonp.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template