开发者

disable or hide ASP listitem using jquery

开发者 https://www.devze.com 2023-03-13 02:39 出处:网络
i have a asp:radio button with two list items asp:RadioButtonList id=Myradio\" asp:listitem1 value=\"li1\"

i have a asp:radio button with two list items

asp:RadioButtonList id=Myradio"
asp:listitem1 value="li1"
asp:listitem2 value="li2"

it is rendered as td for each listitem in horizontal orientation.

What i want to achieve is dynamically on some condition i have to show or hide the list item with value "li2".

i did some thing like this:

$('[value=li2]').hide();

this works but it is only hiding the radio button but not the label generated for that list item. Generated markup: table id开发者_StackOverflow中文版=Myradio tbody tr TD input type="radio" checked="checked" value="li1" name="ctl03$Myradio id="ctl03_Myradio_0" label for="ctl03_Myradio_0" li1 label /td TD input type="radio" checked="checked" value="li2" name="ctl03$Myradio id="ctl03_Myradio_0" label for="ctl03_Myradio_0" li2 label /td

How i can fix that in jquery.

I am sorry i am not good at showing it in proper way.


$('[value=li2]').parent().hide();


If your html is like this

 <label for="li1">Uno</label>
 <input type='radio' id='li1' value='li1'>
 <label for="li2">Dos</label>
 <input type='radio' id='li2' value='li2'>

You can do this:

   $('[value=li2]').hide();
   $('[value=li2]').prev('label').hide();

If you can wrap each label and radio button in a div like this:

 <div>
 <label for="li1">Uno</label>
 <input type='radio' id='li1' value='li1'>
 </div>
 <div>
 <label for="li2">Dos</label>
 <input type='radio' id='li2' value='li2'>
 </div>

Then you can just do this:

  $('[value=li2]').parent().hide();


you can use accordion menu for that i think.

Accordion menu

I think it would be helpful to you.

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消