答案 0 :(得分:1)
1
$("#span1").on('change',function(){
//Do calculation and change value of other span here
$("#span2").text('calculated value');});
2
$("#span1").text('test').trigger('change');
答案 1 :(得分:0)
Srebnywilkun发布的答案是正确的。这个答案只提供了一个简短的表示法。
$("#span1").on('change',function(){
$("#span2").text('calculated value');
}).change(); // defining this at the end of the function would automatically trigger the change event after the event is registered.