Revision: 22836
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 23, 2010 20:51 by PandaWood
Initial Code
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);
});
});
Initial URL
Initial Description
I can't help thinking that good use of jQuery & Javascript must use extensive comments
Initial Title
Can Good jQuery/Javascript not have lots of comments?
Initial Tags
jquery
Initial Language
jQuery