我有这个简单的包装,绑定到onClick
HTML
<button class="button secondary" onclick="editButton(this)">Edit</button>
jQuery
function editButton(edit) {
var row = $(edit).closest('.row'),
cells = row.children().toArray(),
i=0,
inputName = "",
inputValue = "",
html = "";
cells.pop(); // remove control cell
for(i; i<cells.length; i++) {
inputName = $(cells[i]).attr('data-name');
inputValue = $(cells[i]).attr('data-value');
html = "<input type='text' name='"+inputName+"' value='"+inputValue+"'>";
$(cells[i]).html(html);
}
$(row).wrap('<form action="/action_page.php" method="post"></form>');
$(row).wrap('<div class="test"></div>'); //this works!
}
代替包装dom,页面刷新为action_page.php
答案 0 :(得分:1)
您需要停止活动
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
...
mySwitch.addTarget(self, action: #selector(switchChanged(parameter:)), for: .valueChanged)
}
@objc func switchChanged(parameter: UISwitch) {
if mySwitch.isOn {
print("Yeah")
} else {
print("Nope")
}
}
}
答案 1 :(得分:1)
我意识到我需要声明一个没有声明的按钮类型,它默认为type=submit
;
<button class="button button secondary" onclick="editButton(this)">Edit</button>