jQuery:为什么这个警报没有被解雇?
破解演示: http : //jsfiddle.net/sTzCS/52/
如果你去小提琴,你应该能够将列表中的团队拖放到新的订单中。 您还可以输入您认为每个团队将在整个赛季中获得的积分值。 完成重新排列后,jQuery会读取排序顺序,并尝试获取每个团队的输入值。
小提琴中的警报(我为测试目的创建的)应该显示您放在第一位置的团队以及您希望他们获得的积分数量。 但是,警报没有解雇。 jLint说代码是有效的。 我正在使用警报来确保我实际上获得了正确的值。 你能解释为什么警报不起作用吗?
<form
jQuery的
$("#sortlist").sortable({ stop: function(event, ui) { result = $("#sortlist").sortable("toArray"); var attributes; attributes = { first: { team: result[0].id, value: result[0].children()[0].val() }, second : { team: result[1].id, value: result[1].children()[0].val() }, third: { team: result[2].id, value: result[2].children()[0].val() }, fourth: { team: result[3].id, value: result[3].children()[0].val() }, fifth: { team: result[4].id, value: result[4].children()[0].val() }, sixth: { team: result[5].id, value: result[5].children()[0].val() }, seventh: { team: result[6].id, value: result[6].children()[0].val() } }; alert(attributes.first.team + attributes.first.value); } });
$("#sortlist").sortable("toArray")
返回一个可排序项ID的数组,它是一个字符串数组。
字符串没有id
属性和children
方法。