获取<input />的value
$("#id").val( );
标签间的html
$("#id").html('<tr><td>aaa</td> </tr>');
隐藏/显示
$("#id").show(); $("#id").hide();
去字符串的前后空格
$.trim(str);
ID=con标签内的html的追加
$("#con").append('<tr><td>line</td> </tr>');
遍历#con下的所有class为“code”的元素
$("#con .code").each(function(){
value = $.trim( $(this).val() );
}
Ajax代码
$.ajax({
type:'get',
data:"userid="+userid +"&cdkey="+cdkey,
url:"http://www.xxxx.com/gift_ajax.php",
dataType:'html',
error:function(){
alert("error");
},
success:function(data){ switch(data){
case "no_user":
alert("没有此用户!");
break; case "none_or_used":
alert("CDKEY不存在或已被使用!");
break; default:
alert(data);
} }
});