jquery Add attributes and delete attributes in :

$("#2args").attr("disabled",'disabled');
$("#2args").removeAttr("disabled");

The problem background :

choice “ Options 1” yes ,“ Two parameters ” This radio button works .

choice “ Options 2” when , Give Way “ Two parameters ” This radio button on is invalid .

Code :

<!DOCTYPE>
<html >
<head>
<meta charset="utf-8" />
<title>demo</title> <style type="text/css">
.control-group{
margin-bottom: 20px;
}
.controls{
display: inline-block;
vertical-align: top;
}
form{
border:1px dotted #666;
padding: 30px;
display: inline-block;
}
input[disabled],
select[disabled],
textarea[disabled],
input[readonly],
select[readonly],
textarea[readonly] {
cursor: not-allowed;
}
</style>
<body>
<form method="post" action="" onsubmit="return false;">
<div class="control-group">
<label for="project_name"> name :</label>
<input name="project_name" maxlength="20" id="project_name" placeholder=" Project name "></div>
<div class="control-group">
<label> type :</label>
<select id="project_type" onchange="typeChange()">
<option value="" disabled="disabled"></option>
<option value="" disabled="disabled">------ [ Type 1 ] ------</option>
<option value="1"> Options 1</option>
<option value="2"> Options 2</option>
<option value="3"> Options 3</option>
<option value="" disabled="disabled"></option>
<option value="" disabled="disabled">------ [ Type 2 ] ------</option>
<option value="4"> Options 4</option>
<option value="5"> Options 5</option>
<option value="6"> Options 6</option>
</select>
</div>
<div class="control-group">
<label> Parameters :</label>
<div class="controls">
<br/>
<label class="radio" for="1arg">
<input type="radio" name="nodes" id="1arg" value="1" checked="checked" />
Single parameter
</label>
<br/>
<label class="radio" for="2args">
<input type="radio" name="nodes" id="2args" value="2" />
Two parameters
</label>
<br/>
<label class="radio" for="3args" >
<input type="radio" name="nodes" id="3args" value="3" disabled="disabled" />
Three parameters
</label>
</div>
</div> <div class="control-group">
<button id="create_project" type="submit" onclick="beforecreate()"> newly build </button>
<button > Cancel </button>
</div>
</form>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
function typeChange(){
var typeLists=['1','2','3','4','5','6'];
var pj_type=$("#project_type option:selected").val();
if(pj_type==2){
$("#2args").attr("disabled",'disabled');
}else if(pj_type==1){
$("#2args").removeAttr("disabled");
}else if($.inArray(pj_type, app_type_list)>=0){
// Later expansion function
}
}
</script>
</body>
</html>

jquery More articles on tag attribute manipulation

  1. jQuery attr removeAttr Attribute operation

    jQuery attr removeAttr Attribute operation <%@ page language="java" import="java.util.*" pag ...

  2. jquery Study ( Two ) - Attribute operation

    html Code <div class="n1" zdy="z1">AAA <p>1111111</p> <input t ...

  3. jQuery Object's property operation

    jquery The attribute operation module of is divided into four parts :html Attribute operation ,dom Attribute operation , Class style operations and value operations html Attribute operation : It's right html Read the properties in the document , Set and remove operations . such as attr().removeAttr ...

  4. jQuery The problem of getting tag property values

    jquery attr() Unable to get property value. Problem css Liming has already set up : But I still can't get : Seek guidance .   It must be undefined,attr It is used to get or set label properties , Not to get CSS Attribute . If you ...

  5. DOM Object's lookup label &amp; Attribute operation

    HTML DOM ( Document object model ) DOM(Document Object Model) It is a set of methods to abstract and conceptualize the content of documents . JavaScript Yes DOM Implemented , Corresponding to JavaScript in ...

  6. jQuery Native framework ----------------- Attribute operation

    // Add a static method to handle the compatible get style jQuery.getStyle = function( dom, styleName ) { // dom No dom,styleName It's not a string , Straight away i ...

  7. jQuery Basic property operations

    attr and prop,prop It is often used to manipulate the inherent properties of tags , For example checkbox Of checked attribute .select Of selected attribute , and attr It is often used to manipulate the attributes we add to the tag . $('div'). ...

  8. jquery in attr Attribute operation

  9. jquery in val Attribute operation

Random recommendation

  1. [ translate svg course ]svg Medium circle Elements

    svg Medium <circle> Elements , It's used to draw circles , for example <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...

  2. word20161210

    gateway /  gateway gateway account /  gateway account Gateway Service for NetWare / NetWare  Gateway service GDI objects / GDI  object ...

  3. iOS Application architecture view Layer organization and call scheme

    When we start designing View Layer architecture , It's often this App It hasn't started yet , Or this App Several versions have been posted , And then you need to do a very thorough refactoring . In general, they are the two kinds of opportunities to do View Layer architecture , Based on the particularity of this opportunity , We ...

  4. arraylist Addressing

    First of all, I would like to thank my classmates for their ideas . The problem background : hold manage.aspx Medium gridview All of the ID Value into the next page ( Put in arraylist, And pass session Pass on arraylist). Click on ID ...

  5. JDK in DNS Cache analysis

    stay JAVA Use in InetAddress.getByName(String host) Method to get the given hostname Of IP Address . In order to reduce the DNS Number of requests parsed , Improve parsing efficiency ,InetAddress Provided in the ...

  6. Cognos Integrate into portal Platform view report error RSV-BBP-0022

    1. Problem description Absolute closeness request “asynchWait_Request” Failure , The requested session does not exist . 2. Problem analysis Session Session delivery failed . 3. Solution take cognos Address of the server IP Added to the I ...

  7. Rabbit mq Simple application

    Reference resources :http://rabbitmq.mr-ping.com/AMQP/AMQP_0-9-1_Model_Explained.html Simple answer mode (exchange Don't work ) import pika # ...

  8. Golang The pit prevention tips of

    Golang The pit prevention tips of author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . As a little white , I didn't get in touch with programming partners before , It's hard to avoid stepping into some pits , For example, when you first get started, you need to install the environment , Study Gol ...

  9. Use ButterKnife Invalid operation ( Don't complain 、 No effect after clicking )------ Coding error

    Wrong writing ButterKnife.bind(this, inflater.inflate(R.layout.buju, container, false)); return inflater.infl ...

  10. php Get the last week , A month , A year

    <?php date_default_timezone_set('PRC'); /** * Get the last week , A month , A year * */ function getLatelyTime($type = ' ...