5
如何用一個簡單的UI對話框替換此代碼中的提示以實現相同的目的。 IE在使用提示時警告安全。用UI對話框取代提示
HTML:
<input type="text" id="txt1" name="textbox1">
<input type="button" id="btn" name="buttonExecute" value="Enter number">
的JavaScript:
$('#btn').click(function() {
var n = prompt('Please enter number');
if (n!=null && n!="") {
var fixed=n.substr(1,9);
$('#txt1').val(fixed);
}
});
非常好,但我試圖把這個代碼,它不會工作。 var fixed = text2.substr(1,9); $('#txt1')。val(fixed); – Ntguy 2011-03-08 17:47:30
@Ntguy,你需要使用text2.val()。substr(1,9); http://jsfiddle.net/maheshep/5yhmb/21/因爲$('#txt1')返回一個輸入對象而不是字符串。 – Mahesh 2011-03-08 17:53:47
@Ntguy,http://jsfiddle.net/5yhmb/23/其實你的邏輯正確嗎? – Mahesh 2011-03-08 17:55:56