I have a td with follwoing class named 'rgExpandCol' and want to change the class of input inside it. below is my html:
<tr>
<td class="rgExpandCol">
<input class="rgExpand" ...
</td>
<tr>
and I have tried this jquery but I get $find is null:
$(this).closest('td').attr('rgExpand', 'rgCollapse');
EDIT :::
basically am using radgrid
and expanding rows which are hidden using
$(this).closest('tr').next('tr').css('display', '');
and $(this) is on my click event of grid as so
$("#<%=gv.ClientID%> tr:has(td)").click(function (e) {
Use removeClass() and addClass() to make the change.
$("#<%=gv.ClientID%> tr:has(td)").click(function (e) {
e.preventDefault();
$(this).find('input').addClass('rgExpand').removeClass('rgCollapse');
});
Assuming that the id used in the selector identifies the table.
First you need to select the input, which can ben done with a single selector :
var my_input = $(this).find('input.rgExpand');
Then you can remove its current class and add the new one :
my_input
.removeClass('rgExpand')
.addClass('rgCollapse');
$('tr td.rgExpandCol input.rgExpand').removeClass('oldClass').addClass('newClass');
$(this).closest('td').find("input").removeClass("old").addClass("new")
Will apply the CSS for inputs inside the TD :)
Try this:
$('.rgExpandCol > input').removeClass("< existing class >").addClass("< new class >");
So you want to target the td and change the class of the input inside it?
I'd do this:
$('.rgExpandCol > input').removeClass('classtoremove').addClass('newclasstoadd');