下面这几点希望能够帮你加快你的学习。
1.把selectors当作asp.net中的sets。
在asp.net的世界,通过一个查询找到一系列控件是非常少见的.相反我们比较习惯于通过一个唯一的ID来找到一个控件。当然,在jQuery中这个也是没有问题的,但是jQuery的选择功能相对更加神奇。
使用jQuery的selectors能够很容易定位到一个set的元素,相对来说比在asp.net中使用迭代的规则来找到一个set的元素更加清晰和易于表达。
2.使用CSS类来代替styling。
另外一个不直观的技术是把CSS类作为一个flag。与'selector engin'一样,'flag'类也是个令人惊喜的东西。
举个例子来说吧,最近有个活动是做一个在线的能够与客户端互动的纸牌游戏。一个需求是纸牌需要有个onclick haddler在某个特定时间,不过这些事件只针对那些face down(脸朝下)的。作为一个.net的开发者我立刻能够想到的办法是让这些纸牌在客户端通过一个collection来编号.然后我可以在需要的时候给这个数据一个onclick handlers。这个固然可以,不过难以维护且有点凌乱。
现在如果我使用CSS类来实现,face up的纸牌我通过addclass方法为它们加上一个'flipped'类,然后可以通过一个简单的 '$(".card:not(.flipped)")'选择那些face down的纸牌。使用jQuery的click(fn)功能能够让我使用几行代码就实现这个功能。更重要的是它更容易理解和读取。
下面附上几点英文原版的:
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.
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.
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
ASP.NET,jQuery
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
- 中国武警男声合唱团《辉煌之声1天路》[DTS-WAV分轨]
- 紫薇《旧曲新韵》[320K/MP3][175.29MB]
- 紫薇《旧曲新韵》[FLAC/分轨][550.18MB]
- 周深《反深代词》[先听版][320K/MP3][72.71MB]
- 李佳薇.2024-会发光的【黑籁音乐】【FLAC分轨】
- 后弦.2012-很有爱【天浩盛世】【WAV+CUE】
- 林俊吉.2012-将你惜命命【美华】【WAV+CUE】
- 晓雅《分享》DTS-WAV
- 黑鸭子2008-飞歌[首版][WAV+CUE]
- 黄乙玲1989-水泼落地难收回[日本天龙版][WAV+CUE]
- 周深《反深代词》[先听版][FLAC/分轨][310.97MB]
- 姜育恒1984《什么时候·串起又散落》台湾复刻版[WAV+CUE][1G]
- 那英《如今》引进版[WAV+CUE][1G]
- 蔡幸娟.1991-真的让我爱你吗【飞碟】【WAV+CUE】
- 群星.2024-好团圆电视剧原声带【TME】【FLAC分轨】