I have an input textbox which is initially disabled.
<input type="text" name="count" id="count" value="0" disabled="true" data-theme="b" />
When I check a radio button i want to enable and focus the textbox, but when i click the radio button it enables the textbox and focuses some other textbox. I think it does not work because the textbox was initially disabled and you can not focus a disabled input.
$(":input[@name='radio']").live('change', function() {
$(":input[@name='count']").removeAttr("disabled").focus();
});
How do I enable the textbox and then focus it?
It appears it was something wrong with the selector ... although the text input box got enabled, it did not get focused, while I tried:
$(":input[@name='count']").removeAttr("disabled").focus();
But when i tried this, it worked:
$("#count").removeAttr("disabled").focus();
I can not explain why this is happening ...
Edit: It has something to the with the selector, because this works too:
$("input[name='count']").removeAttr("disabled").focus();
but i still can't understand why using the first selector, the textbox gets enabled, but not focused ...
试试下面的代码
$('#count').textinput('enable').focus();
You have to do it on pageshow.
$("#mainPage").on("pageshow", function (e) {
$('#searchField').focus();
});
on
<body class="ui-mobile-viewport ui-overlay-c">
<div data-role="page" data-add-back-btn="true" id="mainPage">
<div data-role="header" data-theme='b'>
<input type="text" id="searchField" placeholder="Search" />
</div>
</div>
</body
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.