如何通过Flask添加/修改HTML属性?

时间:2018-07-23 19:45:50

标签: python html flask jinja2

我在html中有一个按钮,可以这样说:

<button type="button">Button</button>

我希望能够通过烧瓶禁用此按钮(例如,在按下按钮之后)。我想知道的是如何将 disabled 属性添加到按钮上。换句话说,将其变成:

<button type="button" disabled>Button</button>

1 个答案:

答案 0 :(得分:0)

在路线终点致电var vehicleList = [ {vanNumber: "7654628", vanDescription: "VW Campervan", value: {make: "VW", amount: 11660}}, {vanNumber: "9873093", vanDescription: "Renault Campervan", value: {make: "Renault", amount: 3429}}, {vanNumber: "1739566", vanDescription: "Nissan Campervan", value: {make: "Nissan", amount: 5600}}, {vanNumber: "3949219", vanDescription: "VW", value: {make: "VW", amount: 1960}} ]; function collectAndGroupVehicleItemByBrand(collector, vehicleItem) { var list = collector.list, index = collector.index, make = vehicleItem.value.make, group; if (make in index) { group = index[make]; } else { group = index[make] = { make: make, count: 0, list: [] }; list.push(group); } group.count = group.list.push(vehicleItem); return collector; } var dictionary = vehicleList.reduce(collectAndGroupVehicleItemByBrand, { list : [], index : {} }); console.log('groupedVehicleList : ', dictionary.list); console.log('groupedVehicleIndex : ', dictionary.index);时,请传递一个布尔值:

.as-console-wrapper { max-height: 100%!important; top: 0; }

您可以在路线中设置return render_template('template.html', variables=values)的值。然后在您的jinja2模板中,只需放入一个分支:

return render_template('template.html', var1=val1, var2=val2,..., button=button)

如果需要在页面呈现后动态禁用按钮,则@ ltd9938是正确的,则需要使用javascript。

我现在读的意思是在推入之后,是的,是的,您需要使用javascript。