小编use*_*692的帖子

在类选择器中传递jQuery this.id

我有两个不同的输入字段,它使用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对象.

javascript jquery jquery-events

1
推荐指数
1
解决办法
514
查看次数

标签 统计

javascript ×1

jquery ×1

jquery-events ×1