Monday, September 28, 2009

[jQuery] Re: check if checkbox is checked dynamicallyH

$('#priority').click(function(){
    if( $(this).is(':checked') )
        $('.presult').text('500 USD');
    else
       $('.presult').text('');
});

On Mon, Sep 28, 2009 at 05:24, runrunforest <craigcosmo@gmail.com> wrote:

Hi,

I have a html like this

<input type="checkbox" id="priority" /><span class="presult">0 USD</
span>

I want when checkbox is checked, the span will have 500 USD. When
checkbox is unchecked the span will return 0 USD.

This is what I've got, have no idea why not work.

if ($('#priority').is(':checked')) {
           $('.presult').text('500 USD');
   }else {
       $('.presult').text('');
   }

No comments: