Here are a few tips to help you accelerate your study.
1. Treat selectors as a sets in asp.net.
In the ASP.net world, it is very rare to find a series of controls through a single query. Instead we are more accustomed to finding a control through a unique ID. Of course, this is no problem in jquery, but the choice of jquery is relatively magical.
Selectors with jquery makes it easy to navigate to a set element, which is relatively clearer and easier to express than using iterative rules in asp.net to find a set element.
2. Use CSS classes to replace styling.
Another less intuitive technique is to take a CSS class as a flag. Like ' selector Engin ', the ' flag ' category is also a surprising thing.
For example, one recent activity is to do a card game online that interacts with the client. One requirement is that the cards need to have a onclick haddler at a certain time, but these events are only for those faces down (facing down). As a. NET developer I can immediately think of a way to have these cards numbered on the client via a collection. Then I can give this data a onclick handlers when needed. This is OK, but difficult to maintain and a bit messy.
Now if I use a CSS class to implement, face up solitaire I add a ' flipped ' class to them through the AddClass method, and then I can select those cards with a simple ' $ ('. Flipped ') '. Using the jquery Click (FN) feature allows me to use a few lines of code to achieve this feature. More importantly, it is easier to understand and read.
Here are some English originals:
3. Understand unobtrusive JavaScript.
In the ASP.net world, we use a lot of what ' s sometimes termed obtrusive JavaScript. This means is Client-side event handlers are defined as attributes on elements. For example, several ASP.net webcontrols render a onclick= "Javascript:__dopostback ()" attribute as part of their markup. This is considered obtrusive JavaScript.
When ASP.net is initially being developed, this inline JavaScript is the norm. However, as browsers began providing more sophisticated faculties for imperatively adding event handlers, this declarative Technique quickly lost favor with client-side developers. As a consequence, the preferred approach has shifted toward what ' s called unobtrusive JavaScript.
Unobtrusive JavaScript is now considered a best practice when wiring the up Client-side event handlers. This is primarily because it facilitates separation of concerns between JavaScript and behavioral HTML structural. Unobtrusive JavaScript also helps you-write cleaner, more semantic markup, which improves accessibility and often has SEO benefits.
Use the console to learn interactively.
Coming from the save-compile-reload paradigm of statically typed server-side, it's development to natural approach Side development in a similar fashion. While your certainly can write client-side code that way, it's akin to working blindfolded when you consider the Alternativ Es.
Since JavaScript is usually interpreted by a browser, the browser is one of the best debugging environments. In particular, a JavaScript "console" are terrific for interactively interrogating the DOM, testing JQuery selectors agains T actual markup, and refining JavaScript code in real-time.
My preferred browser-based tool is theFirebug addon to Firefox . I cannot praise this Firebug highly enough. It has revolutionized how I approach client-side development, both of JavaScript and of CSS. If you are prefer Internet Explorer, IE8 ' s updated developer tools are also very capable in this DEPA Rtment.
Whatever your browser of choice, I urge you to give these utilities a try-when debugging client-side. Once you become proficient and one of these tools, you'll be amazed this you ever developed Client-side code without it.
Get the vsdoc.
Even though browser-based tools are great for debugging, a asp.net developer ' s primary editor is still going Studio. When writing JQuery code in Visual Studio, has proper Intellisense can make a tremendous difference in productivity. The discoverability that Intellisense provides are especially beneficial when your ' re unfamiliar with JQuery ' s API.
As part of the official support for JQuery, Microsoft provides a documentation file to provide JQuery Intellisense inside Visual Studio 2008. This is provided through what ' s called a Vsdoc file, and are available on the jquery download page (via the "Documentation:visual Studio" Links).
Jeff King has assembled an excellent FAQs to help with Visual Studio 2008 ' JavaScript Intellisense working: span> http://blogs.msdn.com/webdevtools/archive/2008/11/18/ Jscript-intellisense-faq.aspx