jQuery模糊方法,图片代替文字

jQuery blur method, image instead of text

我最近在学习jQuery,想自己尝试一些教程没有说明的东西,我在网上搜索过,但找不到答案。基本上我制作了一个简单的表单文本框,当用户将注意力集中在文本框上但没有输入任何内容并点击其他地方时,一条消息显示 "Forgot to add text?" 但我想要弹出一个图像而不只是文本,我该怎么做?

enter image description here

$("input").blur(函数(){

    if( $(this).val()==""){
        $(this).css('border','sold 1px red');
        $('#box').text('Forgot to add text?');

ps:在 css 中制作了一个黄色的小框,该框内是消息显示的位置,这就是为什么您会看到“#box”

使用 CSS background-image 怎么样?

   if( $(this).val()==""){
        $(this).css('border','sold 1px red');
        $('#box').css('background-image', 'url(url_to_image.jpg)'):       
        $('#box').text('Forgot to add text?');

但不要忘记尺寸和定位。 ;)

没试过,但可以用。