我有两个不同的输入字段,它使用typeahead.
在第一个字段中我们输入Country,在另一个字段中我们应该选择City,具体取决于Country.所以我正在制作一个javascript/jQuery函数,传递字段ID,知道我选择的3对Country + City对中的哪一对.
我正在使用
$('.demoTypeAhead').typeahead({
source: getCityForCountry($(this).id)
});
Run Code Online (Sandbox Code Playgroud)
在函数getCityForCountry中,我想传递一个字段特定的id,但是$(this),或者这都不起作用,因为它返回整个DOM对象.