天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

ASP.NET開(kāi)發(fā)者使用jQuery應(yīng)該了解的幾件事情

下面這幾點(diǎn)希望能夠幫你加快你的學(xué)習(xí)。

1.把selectors當(dāng)作ASP.NET中的sets。

   在ASP.NET的世界,通過(guò)一個(gè)查詢找到一系列控件是非常少見(jiàn)的.相反我們比較習(xí)慣于通過(guò)一個(gè)唯一的ID來(lái)找到一個(gè)控件。當(dāng)然,在jQuery中這個(gè)也是沒(méi)有問(wèn)題的,但是jQuery的選擇功能相對(duì)更加神奇。

   使用jQuery的selectors能夠很容易定位到一個(gè)set的元素,相對(duì)來(lái)說(shuō)比在ASP.NET中使用迭代的規(guī)則來(lái)找到一個(gè)set的元素更加清晰和易于表達(dá)。

2.使用CSS類來(lái)代替styling。

   另外一個(gè)不直觀的技術(shù)是把CSS類作為一個(gè)flag。與'selector engin'一樣,'flag'類也是個(gè)令人驚喜的東西。

   舉個(gè)例子來(lái)說(shuō)吧,最近有個(gè)活動(dòng)是做一個(gè)在線的能夠與客戶端互動(dòng)的紙牌游戲。一個(gè)需求是紙牌需要有個(gè)onclick haddler在某個(gè)特定時(shí)間,不過(guò)這些事件只針對(duì)那些face down(臉朝下)的。作為一個(gè).NET的開(kāi)發(fā)者我立刻能夠想到的辦法是讓這些紙牌在客戶端通過(guò)一個(gè)collection來(lái)編號(hào).然后我可以在需要的時(shí)候給這個(gè)數(shù)據(jù)一個(gè)onclick handlers。這個(gè)固然可以,不過(guò)難以維護(hù)且有點(diǎn)凌亂。

  現(xiàn)在如果我使用CSS類來(lái)實(shí)現(xiàn),face up的紙牌我通過(guò)addclass方法為它們加上一個(gè)'flipped'類,然后可以通過(guò)一個(gè)簡(jiǎn)單的 '$(".card:not(.flipped)")'選擇那些face down的紙牌。使用jQuery的click(fn)功能能夠讓我使用幾行代碼就實(shí)現(xiàn)這個(gè)功能。更重要的是它更容易理解和讀取。

下面附上幾點(diǎn)英文原版的:

3。Understand unobtrusive JavaScript. 
 In the ASP.NET world, we use a lot of what's sometimes termed obtrusive JavaScript.  This means that client-side event handlers are defined as attributes on elements.  For example, several ASP.NET WebControls render an OnClick=”Javascript:__doPostBack()”attribute as part of their markup.  This is considered obtrusive JavaScript.

When ASP.NET was initially being developed, this inline JavaScript was 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 up client-side event handlers.  This is primarily because it facilitates separation of concerns between behavioral JavaScript and structural HTML markup.  Unobtrusive JavaScript also helps you to 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 development, it's natural to approach client-side development in a similar fashion.  While you certainly can write client-side code that way, it's akin to working blindfolded when you consider the alternatives.

    Since JavaScript is usually interpreted by a browser, the browser is one of the best debugging environments available.  In particular, a JavaScript “console” is terrific for interactively interrogating the DOM, testing jQuery selectors against actual markup, and refining JavaScript code in real-time.

    My preferred browser-based tool is the
    Firebug 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 prefer InterNET Explorer, IE8's updated developer tools are also very capable in this department.
    Whatever your browser of choice, I urge you to give these utilities a try when debugging client-side functionality.  Once you become proficient with one of these tools, you'll be amazed that you ever developed client-side code without it.
  • Get the VSDOC.
    Even though browser-based tools are great for debugging, an ASP.NET developer's primary editor is still going to be Visual Studio.  When writing jQuery code in Visual Studio, having proper Intellisense can make a tremendous difference in productivity.  The discoverability that Intellisense provides is especially beneficial when you'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 is available on the
    jQuery download page (via the “Documentation: Visual Studio” links).
    Jeff King has assembled an excellent FAQ to help you get Visual Studio 2008's JavaScript Intellisense working: 
    http://blogs.msdn.com/webdevtools/archive/2008/11/18/jscript-intellisense-faq.ASPx
  • AspNet技術(shù)ASP.NET開(kāi)發(fā)者使用jQuery應(yīng)該了解的幾件事情,轉(zhuǎn)載需保留來(lái)源!

    鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

    主站蜘蛛池模板: 日日噜噜夜夜狠狠扒开双腿 | chinese耄耋70老太性 | 伊人久久大香线蕉avapp下载 | 91国在线产 | 帅哥操美女 | 久久久久久电影 | 日本xxx护士与黑人 日本xxxx裸体xxxx | 亚洲AV成人片色在线观看网站 | 日本无码毛片久久久九色综合 | 欧美激情精品久久久久久不卡 | 九九免费的视频 | 国产 亚洲 中文字幕 在线 | 女人被躁到高潮嗷嗷叫69 | 99国产精品成人免费视频 | 亚洲欲色欲色XXXXX在线AV | 亚洲欧洲免费三级网站 | 51国产午夜精品免费视频 | 亚洲精品第一页中文字幕 | 精品一区二区三区AV天堂 | 超碰免费视频公开97 | 久久婷婷色香五月综合激情 | 涩涩视频在线看 | 久久精品免费电影 | 少妇两个奶头喷出奶水了怎么办 | 大胸美女洗澡扒奶衣挤奶 | 给个男人都懂的网址2019 | 国产高清视频青青青在线 | 国产精品久久久久久久久久影院 | 国产亚洲精品久久综合阿香蕉 | 美女脱内衣裸身尿口露出来 | 色美妞论坛 | 国产精品丰满人妻AV麻豆 | 狠狠色丁香久久婷婷综合_中 | 偷拍久久国产视频免费 | 国产精品A久久久久久久久 国产精品A久久777777 | 美女屁股软件 | 狠狠色狠狠色88综合日日91 | 无码人妻视频又大又粗欧美 | 青草伊人久久 | 在线日本高清日本免费 | 久久综合九色 |