js字符串换行
var sContent =
"<div style=''><h4 style='margin:0 0 5px 0;padding:0.2em 0'>Dfer</h4>" +
"<img style='float:right;margin:4px' id='imgDemo' src='http://www.df315.top/upload/editor/Df%E7%AC%94%E8%AE%B0/Df%E7%AC%94%E8%AE%B0_1710071730384936068.png' width='139' height='104' title='<?php echo $x.",".$y ?>'/>" +
"\
我居北海君南海<br> \
寄雁传书谢不能<br> \
桃李春风一杯酒 <br>\
江湖夜雨十年灯" +
"</div>";
动画效果
$('#hand').animate({'top':-135}, 'slow',function(){
$('#hand').animate({'top':-150}, 'slow')
})
从一个给定的数组arr中,随机返回num个不重复项
var ArrList=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
var ques=getArrayItems(ArrList,7);
function getArrayItems(arr, num) {
var temp_array = new Array();
for (var index in arr) {
temp_array.push(arr[index]);
}
var return_array = new Array();
for (var i = 0; i<num; i++) {
if (temp_array.length>0) {
var arrIndex = Math.floor(Math.random()*temp_array.length);
return_array[i] = temp_array[arrIndex];
temp_array.splice(arrIndex, 1);
} else {
break;
}
}
return return_array;
}
返回某个数值以内的一个随机数
function RandNum(){
var randomNum = Math.random() * 16;
X = parseInt(randomNum, 10);
}