Jquery shows hidden input objects and jqueryinput objects.
1. Enter an input box when selecting another department
#html
<select id = 'deptid' name = 'deptid' class = "select" onchange = 'deptChange ()'>
<c: forEach var = "item" items = "$ {deptidList}" varStatus = "status">
<option value = '$ {item.value}'> $ {item.name} </ option>
</ c: forEach>
</ select>
<!-If the type is other, other departments need to be filled in->
<input id = 'otherDept' name = 'otherDept' type = "text" class = "text" maxlength = '50 'style =' display: none; '/>
// js
// Whether to display other department input boxes according to the switch
function deptChange () {
var deptid = $ ('# deptid'). val ();
// alert ('type:' + hytpye);
if (deptid == 'other') {
$ ('# otherDept'). show ();
} else {
$ ('# otherDept'). hide ();
}
}
How can I change the input type without explicit hiding using jquery?
// Set type $ ('input'). attr ('type', 'text'); $ ('input'). attr ('type', 'Password ');
Indicates whether the jquery interpreter object is hidden.
Upstairs, you can determine the current display status
Of course, you can also use jquery's is to determine whether to hide it.
If ($ ('# id'). is (': visible '))