Soroush Khosravi
Soroush Khosravi

Reputation: 190

Using jQuery to change attributes?

I have a table that in each row there is a checkbox and at the bottom of the table there is a input box that we can enter color name in it (example : fff). and when we click on submit change color of all 'tr' that checked check boxes to the color that we entered in inputbox

Upvotes: 0

Views: 86

Answers (3)

marcusholmgren
marcusholmgren

Reputation: 134

I created a simple example of what I think you want to do. Hopefully it should get you started. Check it out on jsfiddel, http://jsfiddle.net/YGWKA/

Upvotes: 0

Joseph Marikle
Joseph Marikle

Reputation: 78520

You mean like this?

http://jsfiddle.net/GZaqD/

$("#btn").click(function(){
    $("input:checked").parents("tr").css({background:"#" + $("#color").val()});
});

Upvotes: 0

scessor
scessor

Reputation: 16115

It would be easier if we could see your html.

$('form').submit(function() {
    var sColor = '#' + $('input[type="text"]').val();
    $('input:checked').closest('tr').css('background-color', sColor);
    return false;
});

Upvotes: 2

Related Questions