Remove class if checkbox is checked
I want that onload the <span> and <checkbox> classes to be blank:
<span id="checkboxx开发者_如何学编程_<?php  echo $nrs['id'];   ?>" class="highlight" > 
   <input type="checkbox" class="checkboxx" id="checkboxx_<?php  echo $nrs['id'];   ?>" style="padding: 0px; margin: 2px;"   <?php echo $value == 1 ? 'checked="checked"' : ''?>>                       
</span>
i have tried this
<?php
if($value==1)
{
?>
  <script>
    if (this.checked) {
      document.getElementById("checkboxx_<?php  echo $nrs['id'];   ?>").className = "";
    }
  </script>
<?php
} else {
?>
   <script>$j("#"+pos).addClass("highlight");</script>
<?php
}
but this doesn't work.
document.getElementById("MyElement").className =
document.getElementById("MyElement").className.replace(/(?:^|\s)MyClass(?!\S)/ , '')
actually you have duplicate IDs in your  code checkboxx_<?php  echo $nrs['id'];   ?> for span and checkbox, and also this code is buggy and wont work
<script>if (this.checked) {
            document.getElementById("checkboxx_<?php  echo $nrs['id'];   ?>").className = "";
            }
        </script>
i think it will a be better way to use smth like this:
<span class="<?php echo ($value !== 1 ? 'highlight' : '') ?>" > 
   <input type="checkbox" class="checkboxx" style="padding: 0px; margin: 2px;"   <?php echo $value == 1 ? 'checked="checked"' : ''?>>                       
</span>
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论