Search code examples
javascriptjqueryhtmljquery-after

Jquery .after() add image


I'm running a small website. I have an ajax shoutbox.

I have 3 different user class on my website, and on the shoutbox they have a different colors so people know whos who.

I made a supporter class too but thats not an user class, I can select if the user a supporter by checking a radio button yes or no.

And I would like to if the radio is checked yes a small image would appear after the users name.

With php I made it like this for just a test:

if(isset($GLOBALS['user']['supporter'])) {
 $support = 'the image here';
}

My question is: is it possible to make this in jquery?

For like:

if($('global here') == 'supporter') {
  $('class here').after('the image');
}

Can some one please give me a hint?


Solution

  • Well first you would need to get the value of your checked radio.

    supporter = $('#radioButton:checked').val();
    

    Then just execute the code as you have written it assuming that the value of the yes checkbox is '1'...

    if($(supporter == '1')) {
      $('.myClass').after('your markup');
    }
    

    Is this what you are looking for?