English 中文(简体)
unexpected value for $(this+ :checked ).val()
原标题:

I have a radiobutton set called daypattern . Clicking on it should enable the checked member s formfield siblings and disable the formfield siblings (if any) of other members. I am trying to compare the value of the checked field with the value of the current radio button but the checked field value is returning an integer rather than the expected string from the radio button s value attribute.

Where is it getting this number? How can I fix it and is there a better approach?

Thanks

problem function:

    $.fn.setActiveState=function(){
        var c=$(this+ :checked ).val();//c=3 instead of  everyday  OR  everywday . WHY?
        this.each(function(){
          alert(c +   and  + $(this).val());//3 and  everyday  OR  everywday 
          if($(this).val()== c){
            $(this).siblings( :input ).removeAttr("disabled");  
          }else{
            $(this).siblings( :input ).attr( disabled ,true); 
          }
        });
    }

HTML

<label>
  <input type= radio  name= daypattern  value= everyday  checked= checked />Every 
  <input type= text class= numtext  name= day_increment  value= 1 /> day(s)
</label>

<label>
  <input type= radio  name= daypattern  value= everywday />Every weekday
</label>

call problem function in $(document).ready:

$("input[name= daypattern ]").setActiveState();
最佳回答

Try switching to:

$(this).filter( :checked ).val();
问题回答

Try

var c=$( :checked , this).val();//




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签