i want to add a class name in a input field but don’t know the all logic of jquery.
html code is
<tr class="jp_contact"><td>text</td><td>text</td><td>text</td><td><input name="in_val" ></td></tr>
<tr class="jp_contact"><td>text</td><td>text</td><td>text</td><td><input name="in_val" ></td></tr>
<tr class="jp_contact"><td>text</td><td>text</td><td>text</td><td><input name="in_val" ></td></tr>
cod is :
$('.jp_contact').each(function(e){
var currentRow = $(this);
$(this).hover(
function(){
$(this).addClass('jp_hover');
$(currentRow + " td:last").removeClass('dis_button');
},
function(){
$(this).removeClass('jp_hover');
$('input[name="in_val"]').addClass('dis_button');
});
});
Your logic is flawed. On hover, you remove the
dis_buttonclass from the last cell of the current row. When hovering out, you add adis_buttonclass to a non-existent input element.Also, you cannot use jQuery objects in a string context.
$(currentRow + " td:last")should be$("td:last", currentRow)(short for$(currentRow).find("td:last")).