switching on and off in jquery
- by Mac Taylor
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