すべてのリンクを確認して、壊れたリンクフィールドの背景色を変更しようとしています。 CSSが適用されていないいくつかの理由jQuery - 入力要素にCSSスタイルを適用する
<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>
: はここ
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');
}
}); });}
入力フィールドは次のようになります私の関数です。
注:CheckLinks機能は、$(this).css...
部分を除いて機能します。 (FireBug'ed)
注:行が動的に
EDITを追加されています。
function UrlExists(url, cb){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
'$(this).val()'を試してください。 – Sampson
いいえ、あなたの 'UrlExists()'関数の最初のパラメータは '$(this).val()'を持つべきときに '$(this).val'を持ちます。 – Sampson
まだ動作していません... – xperator