I am trying to check all links and change the background color of broken links field. Here is my function
function CheckLinks(){
$('#new_post_links_table tbody>tr').find("input").each(function() {
UrlExists($(this).val(), function(status){
if(status === 404){
$(this).css('background-color','#FC0');
}
}); });}
Input fields looks like this :
<table id="new_post_links_table">
...
<td><input type="text" name="mp3_link[]"/></td>
<td><input type="text" name="mp4_link[]"/></td>
</tr>
</tbody>
</table>
For some reason the css is not applying.
Note: my CheckLinks function does work, except the $(this).css... part. (FireBug'ed)
Note: The rows are added dynamically
EDIT : Here is the function:
function UrlExists(url, cb){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
UrlExists()function has$(this).val, when it should have$(this).val().thisis not mapped to the element that is currently being tested.