Javascript & JQuery & CSS > example - disabled ¿¹Á¦
µî·ÏÀÏ : 2017-07-04 18:42
Á¶È¸¼ö : 53,882
disabledÀº text, radio, select, checkbox ¿¡ °É¾îÁÖ°Ô µÇ¸é submitÀ» ÇÏ´õ¶óµµ disabled°É·ÁÀÖ´Â nameÀÇ value°ªÀº ³Ñ¾î°¡Áö ¾Ê´Â´Ù
±×·¯³ª......
readOnly´Â ³Ñ¾î°£µÂ-0-/
µÎ°¡ÁöÀÇ °øÅëÁ¡Àº ȸé»ó¿¡¼ ÄÁÆ®·Ñ ÇÒ¼ö ¾ø´Ù´Â Á¡.....
ȸé»ó¿¡¼ ¸·¾Æ¹ö¸®°í °ªµµ »ç¿ëÇÒ ÇÊ¿ä°¡ ¾øÀ»¶§...... disabled°É¾îÁÖ°í
ȸé»ó¿¡¼ ¸·¾Æ¹ö¸®Áö¸¸ °ªÀº ¼¼ÆõǼ »ç¿ëÇØ¾ß ÇÒ¶§´Â ..... readOnly°É¾îÁÖ¸é µÈ´Ù.
function disabled_test(chk)
{
var frm = document.all.frm1;
if (chk=="A")
{
frm.test1.style.background="silver";
frm.test1.disabled = true;
frm.test2.style.background="silver";
frm.test2.disabled = true;
//frm.test3.style.background="silver";
frm.test3[0].disabled = true;
frm.test3[1].disabled = true;
frm.test4[0].disabled = true;
frm.test4[1].disabled = true;
}
else
{
frm.test1.style.background="white";
frm.test1.disabled = false;
frm.test2.style.background="white";
frm.test2.disabled = false;
//frm.test3.style.background="white";
frm.test3[0].disabled = false;
frm.test3[1].disabled = false;
frm.test4[0].disabled = false;
frm.test4[1].disabled = false;
}
}
Jquery ¸¦ ÀÌ¿ëÇÑ disabled ¼Ó¼ºÀº ¾Æ·¡ ¿Í °°½À´Ï´Ù.
$("input[name=c_email1]").prop("disabled", false);
$("input[name=c_email1]").prop("disabled", true);
$("input[name=c_email1]").attr("disabled", false);
$("input[name=c_email1]").attr("disabled", true);
//disabled ¼Ó¼º Á¦°Å ¹æ¹ýÀº ¾Æ·¡¿Í °°ÀÌ »ç¿ëÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
$("input[name=c_email1]").removeAttr("disabled");