如果页面中于五个li标签。写个js使点击每个li返回他的index
<!doctype html>
<html>
<head>
<style>
li{cursor:pointer;list-style:none;float:left;width:50px;height:30px;border: solid 1px #7D899E;padding-left:10px;}
</style>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<script type="text/javascript">
$( "li" ).click( function( e ){
alert( jQuery.inArray( this , $("li" ))) ;
});
</script>
</body>
</html>
javascript 有哪几种数据类型
String、Number、Boolean、undefined、Null
window和docuemnt经常使用的属性和方法
window 经常使用的属性和方法:history document pageXOffset pageYOffset parent self location status top navigator alert() blur()
close() confirm() focus() open() print() setInterval() setTimeout()
document经常使用的属性和方法:
body title URL close() getElementById() getElementsByName() getElementsByTagName() write()
求随机数中连续之最大和1、随机生成20个数据,是-1000到1000之间的随意不反复的数据
2、写一个算法,就这一数组的联系的数仅仅和为最大的一组连续数(即数组下班连续的。求出结果的长度可能是随意多个数)。并显示出来
public class Helper {
/**
* 任意一个数组
* @param length 数组长度
* */
public static int[] randInt(int length){
int[]ints = new int[length] ;
for(int x=0;x<ints.length;x++){
int number = randInt() ;
boolean exists = false ;
inner:for(int j=0;j<x;j++){
int temp = ints[j] ;
if(number == temp){
exists = true ;
break inner ;
}
}
if(exists){
x--;
continue ;
}
ints[x] = number ;
}
return ints ;
}
/**
* 求随机数
* */
public static int randInt(){
int result = -1000 + (int)(Math.random() * ((1000 + 1000) + 1)); ;
return result ;
}
/**
* 求数组连续的最大数
* @param ints 数组
* @param max 连续数个数
* */
public static int[] max(int[]ints,int max){
if(max > ints.length){
return ints ;
}
Map<Integer , int[]> tempMap = new HashMap<Integer, int[]>();
for(int x=0;x<ints.length;x++){
int all = 0 ;
int[]tempInts = new int[max] ;
for(int j=x;j<x+max && j<ints.length;j++){
all += ints[j] ;
tempInts[j-x] = ints[j] ;
}
tempMap.put( all , tempInts) ;
}
return tempMap.get(Collections.max(tempMap.keySet() )) ;
}
public static void main(String[] args) {
int[]ints = randInt(20) ;
System.out.println( Arrays.toString( ints ) ) ;
System.out.println( Arrays.toString( max( ints , 3 ) ) ) ;
}
}
现有表名为tb_regorg 的数据表。器数据内容例如以下所看到的,请依据数据规律写出一条SQL语句,查询出现广东及其下属的全部信息
SQL例如以下:
select distinct t1.code , t1.name from tb_regorg t1 , tb_regorg t2 where t1.code like CONCAT(t2.code , '%')
and t2.name like '广东省%'