页面做加法运算
<td id= "count" colspan ="2" align="left">
合计: <span> 50.0</span >分
<script type="text/javascript" >
$().ready( function(){
var count=0;
$.each($( "input[name='value']"),function (index,value){
count=count+parseInt($(value).val(),10);
});
$( "span").text(count);
});
</script>
</td>
jquery常用格式
$().ready(function(){
});页面加载加载
(function($){
})($);闭包
$(function(){})自调函数
自调函数:很有用
1、完成赋值2、声明事件
(function(){
var title = data. versionList[ i]. title;
var content = data. versionList[ i]. content;
var vid = data. versionList[ i]. vid;
$versionA. text( data. versionList[ i]. version);
$versionA. unbind( "click");
$versionA. bind( "click", function(){
kynamic. version. controlDivShow({
addVersion: true ,
showVersionList: false ,
checkIn: false ,
checkOut: true
});
//实现每行的数据都保留下来,具体怎么做到也不清楚
$( "input[name='title']").val(title);
$( "textarea[name='content']").val(content);
});
})();
控制模块显示
kynamic .version .controlDivShow ({
addVersion: true ,
showVersionList: false ,
checkIn: false ,
checkOut: true
});
//统一控制div的显示
controlDivShow: function(divJSON){
if (divJSON .addVersion ) {
$( "#MainArea").show();
}
else {
$( "#MainArea").hide();
}
if (divJSON .showVersionList ) {
$( "#MainArea1").show();
}
else {
$( "#MainArea1").hide();
}
if (divJSON .checkIn ) {
$( "#checkin").show();
}
else {
$( "#checkin").hide();
}
if (divJSON .checkOut ) {
$( "#checkout").show();
}
else {
$( "#checkout").hide();
}
}