我可以使用下面的代码创建一个数组。这个问题是,如果一个人输入50玉米饼,该怎么办?我担心浏览器会遍历查找rel属性的整个列表。
<ul id="taco">
<li rel="19">other html goes here</li>
<li rel="50">other html goes here</li>
<li rel="1535">other html goes here</li>
<li rel="875">other html goes here</li>
</ul>
$("#taco li").each(function() {
$tacoOrder.push($(this).attr('rel'));
});
所以,我想把taco订单值放在输入框中。例如,我的代码看起来像这样。
<input value="19, 50, 1535, 875">
我想从此输入中获取值并创建一个数组。这甚至是可能的,还是更好地完成每项功能?
答案 0 :(得分:1)
这可以是一个解决方案:
def dec(func):
print('times_two' in globals())
def _inner(*args, **kwargs):
print("Decorated")
return func(*args, **kwargs)
return _inner
@dec
def times_two(x):
return x*2
print('times_two' in globals())