以下脚本在我的一台计算机上正常工作,但在另一台计算机上执行时,我得到uncaught referenceerror $ is not defined
。这是另一个类似页面上的相同错误。另外它说无法加载ajax.google ...源的资源。在其他计算机上执行时未捕获ReferenceError
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
//add dynamic fields to add more addresses
$(document).ready(function() {
$('#btnAdd').click(function() {
var $address = $('#address');
var num = $('.clonedAddress').length;
var newNum = new Number(num + 1);
var newElem = $address.clone().attr('id', 'address' +
newNum).addClass('clonedAddress');
//set all div id's and the input id's
newElem.children('div').each (function (i) {
this.id = 'input' + (newNum*11 + i);
});
newElem.find('input').each (function() {
this.id = this.id + newNum;
this.name = this.name + newNum;
});
if (num > 0) {
$('.clonedAddress:last').after(newElem);
} else {
$address.after(newElem);
}
$('#btnDel').removeAttr('disabled');
if (newNum == 2) $('#btnAdd').attr('disabled', 'disabled');//number of
field sets that can be added
});
$('#btnDel').click(function() {
$('.clonedAddress:last').remove();
$('#btnAdd').removeAttr('disabled');
if ($('.clonedAddress').length == 0) {
$('#btnDel').attr('disabled', 'disabled');
}
});
$('#btnDel').attr('disabled', 'disabled');
});
</script>
互联网已关闭。 –
您正在从网上加载jQuery。 '没有互联网=没有jQuery' – Joseph