Re: [問題] Javascrip onClick參數

看板Ajax作者 (肯先生)時間15年前 (2010/05/04 23:23), 編輯推噓3(3013)
留言16則, 6人參與, 最新討論串13/13 (看更多)
題外話,到底需不需要「/>」?用 W3C validation 跑的結果: Below is a list of the warning message(s) produced when checking your document. Line 85, Column 35: NET-enabling start-tag requires SHORTTAG YES <input type='button' value='test'/> The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag <FOO (with an implied '>'). However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.130.232

05/04 23:26, , 1F
講結論: HTML 不需要, XHTML/XML 要
05/04 23:26, 1F

05/04 23:29, , 2F
總之... 努力寫成well formed xml就對了!
05/04 23:29, 2F

05/04 23:44, , 3F
寫成<foo></foo>比較好吧? 有時<foo/>會有問題
05/04 23:44, 3F

05/05 05:11, , 4F
個人習慣會是 <tag attr="value" /> 感覺 "value"/> 小怪
05/05 05:11, 4F

05/05 05:12, , 5F
不過也只是習慣問題… 一般來說有內文的才需要<tag></tag>
05/05 05:12, 5F

05/05 05:12, , 6F
沒內容的像 img 這類的,用 /> close 應該就可以了
05/05 05:12, 6F

05/05 05:13, , 7F
btw 不知道 <foo/> 什麼情況會有問題?可以提出參考一下嘛
05/05 05:13, 7F

05/05 05:14, , 8F
想瞭解一下以後遇到才好避免做這種無意義的debug...
05/05 05:14, 8F

05/05 08:51, , 9F
如果是 html,<img src='xxx' alt=''> 就可以了.
05/05 08:51, 9F

05/05 08:51, , 10F
xhtml 才需要 <img ... />
05/05 08:51, 10F

05/05 08:51, , 11F
同理,html 的話 <br> 即可,無需 <br/>
05/05 08:51, 11F

05/05 08:54, , 12F
/> 的話,/ 都會被 Firefox 塗成紅色的。
05/05 08:54, 12F

05/05 11:46, , 13F
印象中IE捉得到<div id=a></div> 但<divi id=a />捉不太到
05/05 11:46, 13F

05/05 11:47, , 14F
當然其他瀏覽器<div/>是正常的 或許div, span這種比較特別?
05/05 11:47, 14F

05/05 12:01, , 15F
其實最有問題的是 script 一定要有end tag
05/05 12:01, 15F

05/06 07:48, , 16F
原來如此,感謝 tomin !!
05/06 07:48, 16F
文章代碼(AID): #1Bu3lPcH (Ajax)
文章代碼(AID): #1Bu3lPcH (Ajax)