首页
\
问答
\
在Python中,视图和浅拷贝之间有什么区别?(In Python, what's the difference between a view and a shallow copy?)
在Python中,视图和浅拷贝之间有什么区别?(In Python, what's the difference between a view and a shallow copy?)
在NumPy中,我明白切片数组给你一个“视图”,在我看来,它与浅拷贝完全相同。 他们有什么不同?
In NumPy, I understand that slicing an array gives you a "view", which seems to me the exact same as a shallow copy. How are they different?
原文:https://stackoverflow.com/questions/50593483
更新时间:2023-02-23 21:02
最满意答案
你只需要UNBIND一个处理程序
$(document).ready(function() { $('#states').change(function() { $( "#stateinfo").unbind( "keypress" ); var dropdown = $("#states").val(); if (dropdown == "State") { $("#stateinfo").val(""); $("#stateinfo").attr('disabled', 'disabled'); } else if (dropdown == "TX") { $('#stateinfo').keypress(function(e) { var regex = new RegExp("^[0-9]+$"); var num = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(num)) { return true; } e.preventDefault(); return false; }); $("#stateinfo").removeAttr('disabled'); $("#stateinfo").val(""); $("#stateinfo").attr("maxlength", "10"); } else { $('#stateinfo').keypress(function(e) { var regex = new RegExp("^[a-zA-Z0-9]+$"); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; }); $("#stateinfo").removeAttr('disabled'); $("#stateinfo").val(""); $("#stateinfo").attr("maxlength", "15"); } }); });
You just need UNBIND a handler
$(document).ready(function() { $('#states').change(function() { $( "#stateinfo").unbind( "keypress" ); var dropdown = $("#states").val(); if (dropdown == "State") { $("#stateinfo").val(""); $("#stateinfo").attr('disabled', 'disabled'); } else if (dropdown == "TX") { $('#stateinfo').keypress(function(e) { var regex = new RegExp("^[0-9]+$"); var num = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(num)) { return true; } e.preventDefault(); return false; }); $("#stateinfo").removeAttr('disabled'); $("#stateinfo").val(""); $("#stateinfo").attr("maxlength", "10"); } else { $('#stateinfo').keypress(function(e) { var regex = new RegExp("^[a-zA-Z0-9]+$"); var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); if (regex.test(str)) { return true; } e.preventDefault(); return false; }); $("#stateinfo").removeAttr('disabled'); $("#stateinfo").val(""); $("#stateinfo").attr("maxlength", "15"); } }); });
相关问答
更多-
你不能发送两个对象,你必须使用一个具有两个值的对象,否则第二个对象被视为应该是回调的参数 $.get('CheckRollValidity',{roll:rolll, post:postname},function(responseText) { $('#status1').text(responseText); }); You can't send two objects, you'll have to use one object with two values otherwise the ...
-
这可能是因为调用event.stopImmediatePropagation()的另一个处理程序:到目前为止,其他任何处理程序都没有被调用 您可以在浏览器的开发人员工具中查看现有处理程序的元素 Finally I had to replacetag with the