html - CSS Sentence Case -
this question has reply here:
convert uppercase letter lowercase , first uppercase in sentence using css 9 answersis there way format "sentence case"? e.g. "this sentence 1. sentence 2. sentence 3. alter -> sentence 1. sentence 2. sentence 3.
css can convert first letter of each word, not first letter of each sentence. need utilize javascript here:
<html> <head> <script language="javascript"> <!-- function fixcapitalstext (text) { result = ""; sentencestart = true; (i = 0; < text.length; i++) { ch = text.charat (i); if (sentencestart && ch.match (/^\s$/)) { ch = ch.touppercase (); sentencestart = false; } else { ch = ch.tolowercase (); } if (ch.match (/^[.!?]$/)) { sentencestart = true; } result += ch; } homecoming result; } function fixcapitalsnode (node) { if (node.nodetype == 3 || node.nodetype == 4) // text or cdata { node.textcontent = fixcapitalstext (node.textcontent); } if (node.nodetype == 1) (i = 0; < node.childnodes.length; i++) fixcapitalsnode (node.childnodes.item (i)); } // --> </script> </head> <body onload="fixcapitalsnode (document.body);"> first sentence. sec sentence. 3rd sentence. </body> <html>
html css html5 css3
No comments:
Post a Comment