English 中文(简体)
如何在 jquery 中选择选定 Index 的 ID
原标题:how to select the id of selectedIndex in jquery

我想在 jquery 中选择一个 down list 中选中的项目的代号

networkId = $("#availableFbProfiles").selectedIndex.id;

但控制台上的错误是

Cannot read property  id  of undefined
问题回答

尝试此 :

networkId = $("#availableFbProfiles option:selected").prop("id");

如果您重新使用旧版本的 jQuery ( & lt; 1. 7), 使用 < code> attr () 而不是 prop ()

尝试

$("#availableFbProfiles option:selected").get(0).id
networkId = $("#availableFbProfiles option:selected").prop("");




相关问题
adding an index to sql server

I have a query that gets run often. its a dynmaic sql query because the sort by changes. SELECT userID, ROW_NUMBER(OVER created) as rownumber from users where divisionID = @divisionID and ...

Linq to SQL nvarchar problem

I have discovered a huge performance problem in Linq to SQL. When selecting from a table using strings, the parameters passed to sql server are always nvarchar, even when the sql table is a varchar. ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

Move or copy an entity to another kind

Is there a way to move an entity to another kind in appengine. Say you have a kind defines, and you want to keep a record of deleted entities of that kind. But you want to separate the storage of ...

热门标签