Format table column by id using jQuery

Asked

Viewed 30 times

0

I would like to know how to format only the column that the user selects. For this I am using a PHP Loop with While. Each Lopp returns an id to me. My code is as follows:

$('input[type="checkbox"]').click(function(){
  if($(this).is(":checked")){
    var id_check = $(this).attr('id');  //recebe os valores do atributo id do botão clicado
    $("td id="+id_check).css("color", "red");
   }
   else if($(this).is(":not(:checked)")){
     $("td id="+id_check).css("color", "green");
   }
 }); 

I will not put the PHP Loop because it is too long, but the principle is that the <input type=checkbox> has an id.

  • I just don’t understand what you want to do at the end. Ask your html too

1 answer

0

If you are sure that the id’s are unique, you can do so:

$("#"+id_check).css("color", "red");
  • That way it didn’t work. But thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.