3
我使用的是AngularJS,當一個特定的輸入被點擊/焦點時,我想要一個與該輸入相關的列表項目移動到列表頂部(最好是從頂部向下推)AngularJS使用ng-focus將列表項目移動到列表頂部
我一直在嘗試一些技巧,包括ng-focus和ng-if,但沒有任何運氣讓它正常工作。
任何幫助將不勝感激。
HTML
<label class="control-label">Motive :</label>
<input type="number" ng-model="payment.cash" ng-focus="addItem()" />
<br>
<label class="control-label">Employment Type :</label>
<input type="number" ng-model="payment.check" ng-focus="addItem()" />
<br>
<label class="control-label">Money Order :</label>
<input type="number" ng-model="payment.money_order" />
</div>
<div class="oneHalf">
<h2>Help Text</h2>
<ul class="help-text">
<li>
<h3>Motive</h3>
<p>What made you go online today? What spurred you into action? Cost, Replacing cover, Family, job change What did you see online that appealed to you?</p>
</li>
<li>
<h3>Employment Type</h3>
<p>Self employed - explain net profit (taxable income) Contracts - renewable? how many time renewed? Cover only applies to end of contract</p>
</li>
<li>
<h3>Budget</h3>
<p>What can the client comfortably afford? Check against salary</p>
</li>
<li>
<h3>Industry</h3>
<p>Check the Trent watch list clack here</p>
</li>
<li>
<h3>Life Sum</h3>
<p>There is no normal<br>
Salary x years of dependancy<br>
10 x Salary<br>
Funeral - what impact will inflation have on the sum assured!</p>
</li>
</ul>
JS:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
}
CSS
.oneHalf {
width:50%;
float:left;
}
ul, li {
list-style:none;
margin:0;
padding:0;
}
.help-text {
position:relative;
}
.test {
background:red;
display:block !important;
}
你有沒有我可以合作的例子? – DBoi