get value from input text from selected tab with jquery
I am using jquery tabs. I have three tabs. Each tab has its own input text field (one per tab). All three input text fields have the same id="javanus" but they are on a different tabs.
I would like to get the value from the input text field on the selected tab for id=javanus . I could get the sel开发者_JS百科ected tab text (alert($('.ui-tabs-selected a').attr("text")) but I do not know how to read the value from the selected panel for selected tab.
Best regards, Javanus
As has already been said you cannot have two elements with the same ID on one page, but you can have many elements with the same class. When you change every id="javanus" to class="javanus" it will be ok, but unfortunately you can't use $('.ui-tabs-selected ...') because the ui-tabs-selected class is present only on the header of an active tab, not on its panel. What you have to use is something like this:
$(".ui-tabs-panel:not(.ui-tabs-hide) input:text.javanus").val();
which means to get the tab panel that is not hidden, get a text input element with class "javanus" inside and get its value. Does it do what you need?
精彩评论