2011-11-04 27 views
1

我有一块代码,通过它我将输入的标题更改为跨度。旁边是我的形象,虽然它被设置为隐藏显示。更改图像attibute到使用jquery

<div class="field"> 
    <input type="text" name="email" class="w_def_text" id="email" title="Email*" /> 
    <img width="27" height="27" src="images/error.png" alt="Error"> 
</div> 

我已经改变了这个作为使用jQuery的跨度。现在,我正在模糊事件上发送输入值。

$('#email').blur(function() { 
var email = $('#email').val(); 
(1.) $(this).next('img').show().html('<img width="80" height="27" src="images/dot.gif" >'); 
$.post('showuserstatus.php', { 
    emailid: email 
}, function(data) { 
//$('#erroremail').show().html(data); 
(2.) $(this).next().next().html(data); 

    }); 
}); 

在这两个我想改变形象src中的一点,那就是在发送响应。并在收到回应后。

注意:我已经使用.next.next,因为我有两者之间的跨度。所以第二个是图像。

+0

$(本)。接下来()next()的HTML(数据)。;这里将指向当前文档而不是电子邮件输入。 – sathis

+0

yup ...但是,因为我使用这种模糊的电子邮件,所以它的工作... –

回答

5

使用

$(".field img").attr("src", "images/dot.gif"); 
+0

它应该是'$(“img”)。attr(“src”,“images/dot.gif”);'作为我没有'$(“。field img”)'类。 –