Hi im working with a mask plugin and I need to add a class to an input level element, however I can't seem to target it correctly, and .next() simply goes on to the next level <td>.
Here is a Jfiddle I'm working on as you can see I need the phone_us part to be added dynamically to the class attribute because im masking it<input type="text" class="" name="" value="">
Javascript
$(document).ready(function(){
$('td').each(function (index) {
var divHTML = $(this).text();
if(divHTML.indexOf("Phone") >= 0)
{
$(this).next().css('background-color', 'blue');
$(this).next().closest('input').addClass('phone_us');
$('.phone_us').mask('(999) 999-9999');
}
});
});
HTML
<td class="label">Phone #</td>
<td class="field"><input type="text" class="label_box" name="" value=""></td>