移动代码
JS代码:
function getElementsByClass(searchClass,tagName) {
var classElements = new Array();
if ( tagName == null )
tagName = '*';
var els = document.getElementsByTagName(tagName);
var elsLen = els.length;
var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
function ccMarquee(className){
var a=getElementsByClass(className);
for (i = 0; i < a.length; i++) {
a[i].innerHTML="<marquee>"+ a[i].innerHTML+"</marquee>";
}
}window.onload = function () {
ccMarquee("ccMarquee");
}
function getElementsByClass(searchClass,tagName) {
var classElements = new Array();
if ( tagName == null )
tagName = '*';
var els = document.getElementsByTagName(tagName);
var elsLen = els.length;
var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
function ccMarquee(className){
var a=getElementsByClass(className);
for (i = 0; i < a.length; i++) {
a[i].innerHTML="<marquee>"+ a[i].innerHTML+"</marquee>";
}
}window.onload = function () {
ccMarquee("ccMarquee");
}
XHTML代码:
<div class="ccMarquee">
<a href="" title="">这里是滚动的</a>
</div>