我有几个弹出窗口有多个输入字段。我想强调我的所有弹出窗口的FIRSTinput元素,我不想使用IDS:使用jquery突出显示弹出框的第一个输入元素
我的代码:
function initPopups(){
$('*[id*=Popup]').each(function() {
$(this).on({
// disables the auto close on outer clicks
popupbeforeposition: function() {
// removes all handlers from the 'background'(-layer.class) of the popup
$('.ui-popup-screen').off();
},
// SHOULD highlight the first textfield after popup opened
popupafteropen:function(){
console.log("OPENED");
$('form:first *:input[type!=hidden]:first').focus();
}
});
});
这里有一个弹出式的HTML:
<div data-role="popup" id="create_stationPopup" class="ui-content">
<a href="#" data-rel="back" data-role="button" data-theme="c" data-icon="delete" data-iconpos="notext"
class="ui-btn-right">Close</a>
<form>
<input type="text" name="name" id="station_input_title" value="" data-mini="true" placeholder="Titel der Station" />
<input type="text" name="name" id="station_input_number" value="" data-mini="true" placeholder="Nummer der Station"/>
<textarea name="textarea" id="station_input_text" placeholder="Beschreibe diese Station"></textarea>
</form>
<a href="#create_stationQuestionPopup" data-rel="popup" data-role="button" data-theme="c" id="createWave_questionBtn" >Frage
hinzufügen</a>
<a id="createWave_stationSaveBtn" data-role="button" data-theme="c">Station
speichern</a>
</div>
我的代码只突出显示我的HTML文件中的第一个输入字段,而不是所有弹出窗口中的第一个输入字段(它们都是静态html)
你正在使用什么插件,从问题其不明确:( – sakhunzai
这是使用jQuery手机? – David
jquery mobile yes。 – MJB