if(var i = 1;){
如果if(var i = 1;){
等被删除并且就item.text("Options for your number " + i +"th $Name");
在那里,代码似乎无法正常工作。
<script type='text/javascript'>//<![CDATA[
$('#Quantity').keyup(function () {
var textualValue = $(this).val();
var numericValue = parseInt(textualValue, 10);
if (!isNaN(numericValue)) {
modifyDOMWithNumber(numericValue);
} else {
modifyDOMWithNumber(0);
}
});
function modifyDOMWithNumber(number) {
var ul = $('ul#ListToAlter').empty();
var item;
for (var i = 1; i <= number; i++) {
item = $("<li>");
if(var i = 1;){
item.text("Options for your 1st $Name");
}elsif(var i = 2;){
item.text("Options for your 2nd $Name");
}elsif(var i = 3;){
item.text("Options for your 3rd $Name");
}else{
item.text("Options for your number " + i +"th $Name");
}
ul.append(item);
}
}
//]]></script>