Now there is a need to select all the elements that have background images.
This problem is a bit tricky. We can't use the select expression to complete this problem.
Using jquery's Dom filtering method filter (), you can select elements based on
jquery has two methods for developing Plug-ins, respectively:
JQuery.fn.extend (object);
Jquery.extend (object);
Jquery.extend (object); To extend the jquery class itself. Adds a new method to the class.
JQuery.fn.extend (object); Add methods to
Look at an example:
Copy Code code as follows:
When the page containing the above code is opened, it does not load "tt.jpg" and is loaded when the button is clicked. Triggers the onload event to appear on the page when
Here's a way to scroll the DIV's scroll bar to the location of its child elements to facilitate automatic positioning.
Copy Code code as follows:
var container = $ (' div '),
Scrollto = $ (' #row_8 ');
Container.scrolltop (
Copy Code code as follows:
var evt = window.event | | Arguments[0];
Here are three ways to add events to your discussion, and you may see a way to get things you haven't seen before.
1, the first way to add events, directly in the
The method basically comes from the source code in the thinkphp, but has been modified by me
Copy Code code as follows:
/*
* @Description: Delete HTML tags and get plain text. can handle nested labels
*
*/
Class deletehtmltags{
The principles of jquery writing:
First, do not overdo the use of jquery
1. jquery is faster than the native JavaScript method, and the created jquery object contains a huge amount of information. So there are occasions where native methods can be
Today, when you write jquery, you have a problem: when you add element xxx dynamically using a script, but the event $ (". x. Y"). Click (function) ... Failure problem.
Just started to find a live function on the Internet, the following method:
One, use each traversal
Copy Code code as follows:
$ (function () {
var tbody = "";------------traverse the object. Use of each-------------Object syntax JSON data format (when the server-side callback returns the object data format
For example, a web chat room, the scroll bar will automatically scroll down as the content increases.
When the user clicks on the scroll bar, we can assume that he or she is browsing the chat content, then the good user experience will not allow the
Get text method in IE innertext not supported in Firefox
Firefox changed to Textcontent method/attribute
And the whitespace in the middle of the Firefox Chinese text is replaced by a ruthless replacement.
It's extremely inconvenient to use.
Now
Animated Opening Type (tutorial)
Beautiful text open effect, very interesting.
View Demo
Direction-aware Hover Effect with CSS3 and Jquery (tutorial)
Hover effect of the mouse to follow the tutorial, saying before see this is very popular.
View
This example describes the use of the Dequeue () method in jquery. Share to everyone for your reference. The specific analysis is as follows:
This function can remove a queue function from the top end of the queue and execute it.It is recommended
This example describes the use of the Post method in jquery and shares it for your reference. The specific usage analysis is as follows:
When using jquery to implement asynchronous interactions in a Web site, the two functions commonly used are get
itself method ($.each,$.map,$.contains, $ajax)
Common tool Methods
(1) $.trim
The $.trim method removes extra spaces from the head and tail of the string.
Copy Code code as follows:
$.trim (' hello ')/hello
(2) $.contains
Today we want to share a very useful jquery plug-in, it is based on the jquery multi-level linkage of the provinces and cities select Drop-down box, and it is worth mentioning that this linkage drop-down box is a custom beautification, the
Modify or Extend jquery's method code example:
There is no doubt that jquery is a powerful and easy to use class library.
From its wide application can confirm the above point of view, but the so-called no one is perfect, gold without pure, jquery
Fine read this article, enough for you to optimize a half-day, about the JS optimization methods are mostly out of these three methods.
(Total page size is 155.k, and JS takes up 100.3K)
It's time to optimize the next JS.
About JS optimization
When it comes to types of Web pages, you often encounter the need to see the big picture, LightBox2 is the most excellent in many products, a jquery plug-in. Configuration is not in detail, today I would like to share the main: How to open a large
Dynamic request data to update the page is now a very common method, such as blog comments page dynamic loading, micro-blog scrolling load and timed request loading.
In these cases, the data returned by the dynamic request is generally not a
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