好的jQuery/Javascript不能有很多注释吗?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了好的jQuery/Javascript不能有很多注释吗?相关的知识,希望对你有一定的参考价值。
I can't help thinking that good use of jQuery & javascript must use extensive comments
var grammar = { BracedText : new RegExp('{.*}') }; $(function() { $('td.kanji').each(function() { // get text is in curly-braces, abort if nothing var sentence = $(this).text(); var $bracedText = sentence.match(grammar.BracedText); if ($bracedText === null) return; var bracedText = $bracedText[0].substr(1,$bracedText[0].length-2); // replace curly-braced text with a span, which serves as an insertion point sentence = sentence.replace(grammar.BracedText,'<span></span>'); // find first link, clone it var link = $(this).closest('tr').find('a:first').clone(); // change the link text to what was in the curly braces link.text(bracedText); //insert the new html $(this).html(sentence).find('span').append(link); }); });
以上是关于好的jQuery/Javascript不能有很多注释吗?的主要内容,如果未能解决你的问题,请参考以下文章