Ang pangunahing problema sa hindi pagpapagana at pagpapagana ng input ay maaari itong magdulot ng hindi inaasahang gawi. Halimbawa, kung hindi mo pinagana ang input sa isang form, maaaring hindi maisumite ng mga user ang form.
field To disable an input field in jQuery, use the prop() method. To enable an input field in jQuery, use the removeAttr() method. Example You can try to run the following code to learn how to enable and disable input field − <html> <head> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20src%20%3D%20%22https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F3.2.1%2Fjquery.min.js%22%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" /> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%3E%20%24(document).ready(function()%7B%20%24(%22%23btn1%22).click(function()%7B%20%24(%22input%22).prop(%22disabled%22%2C%20true)%3B%20%7D)%3B%20%24(%22%23btn2%22).click(function()%7B%20%24(%22input%22).removeAttr(%22disabled%22)%3B%20%7D)%3B%20%7D)%3B%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<script>" title="<script>" /> </head> <body> <p><b>Note:</b> This example does not work in Internet Explorer 8 and earlier versions.</p> Name: <input type = "text" id = "test"> <button id = "btn1">Disable</button><br><br><br><br><br><br><br><br><br></body></html>
Mga Pindutan
Ang mga pindutan ay isang karaniwang elemento sa jQuery. Magagamit ang mga ito para gumawa ng mga simpleng button, o mas kumplikadong mga button na may mga tagapangasiwa ng kaganapan.
Para gumawa ng simpleng button, gamitin ang
Para gumawa ng mas kumplikadong button, gamitin ang
Payagan hindi payagan
Ang Enable at Disable ay dalawang jQuery function na nagbibigay-daan sa iyong kontrolin ang visibility ng mga elemento sa isang page.