外部文件中的大写脚本:
function capitalise(str) {
if (!str) return;
var counter = 0;
var stopWords = ['is','a','an','and','at','but','by','far','from','if','into','in','of','off','on','or','so','the','to','up','with'];
str = str.replace(/\b\S*[a-z]+\S*\b/ig, function(match) {
counter++;
return $.inArray(match, stopWords) == -1 || counter === 1 ? match.substr(0, 1).toUpperCase()+match.substr(1) : match;
});
return str;
}
内联JavaScript:
<ul class="nav-swap-video">
<li><a id="nav-content1" class="" href="#st-mv1" onclick="changeVideo('../video/video_arriving.mpg');setTagContents('heading', 'Arriving');switchButton('1')" title="Arriving">Arriving
<div class="video-nav-bottom"></div>
</a>
</li><li><a id="nav-content2" href="#st-mv2" onclick="changeVideo('../video/video_in_bag.mpg');setTagContents('heading', 'In the bag');switchButton('2')" title="In the bag" class="">In the bag
<div class="video-nav-bottom"></div>
</a>
</li><li><a id="nav-content3" href="#st-mv3" onclick="changeVideo('../video/video_getting_ready.mpg');setTagContents('heading', 'Getting ready');switchButton('3')" title="Getting ready" class="nav-on-xx">Getting ready
<div class="video-nav-bottom"></div>
</a>
</li><li><a id="nav-content4" href="#st-mv4" onclick="changeVideo('../video/video_after_swim.mpg');setTagContents('heading', 'After a swim');switchButton('4')" title="After a swim" class="">After a swim
<div class="video-nav-bottom"></div>
</a>
</li></ul>
我需要在设置标记内容后将其大写。
1条答案
按热度按时间p8h8hvxi1#