jquery當中each type text的用法
阿新 • • 發佈:2021-12-31
jquery當中each type text的用法
例 1.11(each&add&[type&text.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript" src="jquery.min.js"></script>
</head>
<body>
<input value="11" /> +
<input value="22" />
<input type="button" value="=" />
<label>0</label>
<script type="text/javascript">
$("input[type='button']").click(function(){undefined
var sum = 0;
$("input[type='text']").each(function(){//每個都執行一遍function
sum += parseInt($(this).val());
});
$('label').text(sum);
});
</script>
</body>
</html>
更多內容請見原文,文章轉載自: https://blog.csdn.net/qq_44594371/article/details/103054317