I see where you're changing background colors, but where are you trying to
change colspans?

untested, but

     $('myTDelement').attr('colspan', x);

... where 'x' is the numeric value, should work.

also, it's criminal to use document.getElementById() within jQuery.
$('#element') is so much more elegant :)

<script type="text/javascript">
    $(document).ready(function() {
        $('#plusSign').click(function() {
            $('.ba_toggle').toggle();

               if $('#plusSign').html() == "+") {
                   $('#plusSign').html('-');
                $('th.ba_colspan, td.ba_colspan').each(function() {
                    $(this).attr('bgColor','red');
                });
               } else {
                   $('#plusSign').html('+');
                $('th.ba_colspan, td.ba_colspan').each(function() {
                    $(this).attr('bgColor','green');
                });
               }

           });
    });
</script>


On Thu, Dec 17, 2009 at 11:23 AM, davec <dcah...@hyphensolutions.com> wrote:

> I am trying to change the colspan attribute on some table cells when
> the user clicks on a button but it is not affecting the table. Perhaps
> someone can tell me what I am doing wrong. Here is my jQuery code:
>
> <<script type="text/javascript">
> $(document).ready(function() {
>   $('#plusSign').click(function(){
>      $('.ba_toggle').toggle();
>        if(document.getElementById('plusSign').innerHTML=='+')
>        {
>           document.getElementById('plusSign').innerHTML='-';
>           $('th.ba_colspan, td.ba_colspan').each(function(){
>                $(this).attr('bgColor','red');
>           });
>        }
>        else
>        {
>            document.getElementById('plusSign').innerHTML='+';
>            $('th.ba_colspan, td.ba_colspan').each(function(){
>                $(this).attr('bgColor','green');
>            });
>        }
>     });
>  });
> </script>
>



-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to