我正在使用http://designwithpc.com/Plugins/ddSlick#demo。一个使用图像、文本等自定义下拉菜单的插件。当我从下拉列表中选择一个选择选项时,我试图获取文本,但我的浏览器控制台日志显示未定义。我已经尝试将数据放入第 7 行的变量中,但它仍然给了我相同的结果。
$('#myDropdown').ddslick({
data:ddData,
width:300,
selectText: "Select your preferred social network",
imagePosition:"right",
onSelected: function(selectedData){
var selectedData = $('#myDropdown').data('ddslick');
console.log(selectedData.text);
}
});
这是ddData的结构:
var ddData = [{
text: "Facebook",
value: 1,
selected: false,
description: "Description with Facebook",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
}, {
text: "Twitter",
value: 2,
selected: false,
description: "Description with Twitter",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
}, {
text: "LinkedIn",
value: 3,
selected: true,
description: "Description with LinkedIn",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"
}, {
text: "Foursquare",
value: 4,
selected: false,
description: "Description with Foursquare",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"
}];