我是新来的朋友我有一个JQ的问题代码 [英] Friends I am new here I have a question code of JQ
本文介绍了我是新来的朋友我有一个JQ的问题代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<html>
<head>
<title>Page Title</title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<p value="223">JQuery is </p>
<!--!The code prints an integral number like 4! But I'm actually a decimal number 4.4-->
<p value="4.4">JQuery is </p>
<div></div>
</body>
<script type="text/javascript">
$( document ).ready(function() {
var arr=new Array(); $('p').each(function() {
$(this).click(function() {
arr.push($(this).attr("value"));
var total = 0;
$.each(arr,function(i) {
total += arr[i] << 0;
$("div").html(total);
});
});
});
});
</script>
</html>
< b>我尝试了什么:
我试图创建ARRAY并尝试连接
What I have tried:
I tried to create ARRAY and try to connect the result of all the values inside
推荐答案
( document ).ready( function (){
var arr = new 数组( );
( document ).ready(function() { var arr=new Array();
(' p')。每个(< span class =code-keyword> function (){
( this )。click(功能(){
arr.push(
(this).click(function() { arr.push(
这篇关于我是新来的朋友我有一个JQ的问题代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文