switching on and off in jquery

Posted by Mac Taylor on Stack Overflow See other posts from Stack Overflow or by Mac Taylor
Published on 2010-05-07T07:22:35Z Indexed on 2010/05/07 7:28 UTC
Read the original article Hit count: 138

Filed under:

hey my friends

i wrote a code to switch on or off the status of a story ( activate or deactivate )

this is my html part :

$status_link = $active==1 ? "active.gif" : "inactive.gif";

<span id='status_link'>
<a class='change_status' href='javascript:void(0)' id='$pid'>
<img src='images/$status_link' class='active_status' id='$active'></a>
</span>

and this is my jquery code :

<script type="text/javascript">$(function(){

    $('.change_status').each(function(){
        var pid=$(this).attr('id');

    $('.active_status').each(function(){
        var type=$(this).attr('id');

        .click(function(){
$.post("change_status.php"+"&type="+type+"&pid="+pid, function(data){
$('#status_link').html(data).fadeIn("slow");
 });
 return false;
 });
});
</script>

and a php function that is easy, i dont think its needed

i myself think there is a problem with my jquery code

how can i change the picture of that image by clicking on it

© Stack Overflow or respective owner

Related posts about jQuery