小编Pra*_*lan的帖子

.on()来自for循环?

在我目前的项目中,我有这样的多行:

$$(document).on('change','#x1', function () {
   console.log('fired');
});
$$(document).on('change','#x2', function () {
   console.log('fired');
});
$$(document).on('change','#x3', function () {
   console.log('fired');
});
Run Code Online (Sandbox Code Playgroud)

是否有可能用一些for循环替换它?(我的例子不起作用)

for (var i = 1; i < 4; i++) {
   $$(document).on('change','#x'+i, function () {
   });
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery

0
推荐指数
1
解决办法
53
查看次数

选中复选框后,禁用其他相同值复选框

选中一个时,如何禁用其他相同值复选框.

<input type='checkbox' name='check[]' value = '1'>
<input type='checkbox' name='check[]' value = '2'>
<input type='checkbox' name='check[]' value = '1'>
<input type='checkbox' name='check[]' value = '2'>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

0
推荐指数
1
解决办法
690
查看次数

Spring Security antMatcher表达式不适用于路径变量

我需要提供某些角色来访问以下格式的URL:

/connector/{programId}/order/{anything here}
Run Code Online (Sandbox Code Playgroud)

programId整数值在哪里,所以我尝试了以下操作,但它根本不起作用。

/connector/{programId}/order/{anything here}
Run Code Online (Sandbox Code Playgroud)

但是,当我使用它**而不是programId零件时,它运行良好。但是,如何使它与pathVariable(始终为整数)一起使用。

java regex configuration spring spring-security

0
推荐指数
1
解决办法
1481
查看次数

胖箭头功能无法使用jquery getJSON?

我试图用新的=>表示法将回调绑定到jQuery getJSON命令,但它不起作用.

旧代码(作品)

$.getJSON("js/questions.json", function(data){
   console.log("loaded json but lost my scope...");
});
Run Code Online (Sandbox Code Playgroud)

胖箭(不工作)

$.getJSON("js/questions.json", (data) => this.test);
function test(data){
     console.log("If we get here we might still have our scope");
}
Run Code Online (Sandbox Code Playgroud)

jquery ecmascript-6

-1
推荐指数
1
解决办法
335
查看次数

jQuery sum表格单元格

求和表单元格

<table>
    <tr>
        <td><input type="text"></td>
        <td><input class="price" type="text" value="100"></td>
        <td><input class="quantity" type="text" value="2"></td>
        <td><input type="text"></td>
    </tr>
    <tr>
        <td><input type="text"></td>
        <td><input class="price" type="text" value="100"></td>
        <td><input class="quantity" type="text" value="5"></td>
        <td><input type="text"></td>
    </tr>
    <tfoot>
        <tr class="summary">
            <td>Total:</td>
            <td id="total_price"></td>
            <td id="total_quantity"></td>
            <td class="second"></td>
            <td class="third"></td>
        </tr>
    </tfoot>    
</table>


<script>
    $(document).ready(function() {
        var sum = 0;
        var quantity = 0;
        $('.price').each(function() {
            sum += (parseInt($('.price').val()) * parseInt($('.price').val()));
            quantity += parseInt($('.quantity').val();
        });

        $('#total_price').html(sum);
        $('#total_quantity').html(quantity);
    })
</script>
Run Code Online (Sandbox Code Playgroud)

输出必须是:总和:700; 总数量:7

html javascript jquery

-3
推荐指数
1
解决办法
2万
查看次数

是否可以降低HTML中图像中的单击不透明度?

我试图降低点击图像的不透明度,但我不知道这是否可能,我可以使用HTML和JavaScript.

html javascript

-3
推荐指数
1
解决办法
108
查看次数

JavaScript:使用for循环生成对象

所以例如我总共有3个数组,如下所示

var arr1 = ['123','456','789'];
var arr2 = ['435','551','778'];
var arr3 = ['5','7','1'];
Run Code Online (Sandbox Code Playgroud)

我试图将它们存储在一个对象中以供进一步使用.

       var Chart = "";
        for(var i = 0; i < arr1.length ;i++){

             Chart = {
                    x : arr1[i],
                    y : arr2[i],
                    z : arr3[i]
                };

        }
Run Code Online (Sandbox Code Playgroud)

我的方法完成了这项工作,但是当我控制它并使用它时它只返回最后一组数据.

所以只有 {arr1[2],arr2[2],arr3[2]}用过其余的都没有了.

我怎么能解决这个问题?

javascript

-3
推荐指数
1
解决办法
72
查看次数