javascript - Not able to show/hide div using Jquery on Asp.Net RadioButtonList item selection? -


i have asp.net radiobuttonlist control , want hide or display these based on radiobuttonlist selection change using jquery. please guide me why not able when using same code in

my aspx

<asp:content id="content1" contentplaceholderid="head" runat="server"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type = "text/javascript"></script>  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type = "text/javascript"></script>  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel = "stylesheet" type="text/css" /> <script type="text/javascript">     $(document).ready(function () {         $('#rdbrawmtrl input').click(function () {             var value = $('#rdbrawmtrl input:checked').val();             if (value == "cotton") {                 $("#abc").show();                 $("#panel6").hide();             }             if (value == "wool") {                 $("#panel6").show();                 $("#abc").hide();             }         });     }); </script> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <asp:radiobuttonlist id="rdbrawmtrl" runat="server" style="margin: 0 4px 8px 0;">                             <asp:listitem>cotton</asp:listitem>                             <asp:listitem>wool</asp:listitem>                 </asp:radiobuttonlist> <div id="abc" runat="server" style="display:none;"> //some more controls </div> <div id="panel6" runat="server" style="display:none;"> //some more controls </div> </asp:content> 

i have tried display jquery variable "value" showing no result.

<script type="text/javascript">     $(document).ready(function () {         $('#rdbrawmtrl input').click(function () {             var value = $('#rdbrawmtrl input:checked').val();             alert(value);         });     }); </script> 

please guide me doing wrong.

you can not html element through id in javascript directly. asp.net server side language , javascript client side need client id . try ..

$('#<%=rdbrawmtrl.clientid%>').click(function(){       // code here .... }); 

Comments