这是使用的代码
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="twitter-bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet"/>
<link href="twitter-bootstrap/docs/assets/css/docs.css" rel="stylesheet">
<link href="twitter-bootstrap/docs/assets/js/google-code-prettify/prettify.css" rel="stylesheet">
<style type="text/css">
.container
{
width: 750px;
height : 300px;
margin-top : 50px;
}
</style>
</head>
<body>
<div class = "container">
<div class = "well" style = "box-shadow : 0 1px 10px rgba(0,0,0,1.0);">
<form id = "reg" class = "form-horizontal" method = "post" action = "reg.php">
<legend>Registration form</legend>
<div class = "control-group">
<label class = "control-label">Login name</label>
<div class = "controls">
<div class = "input-prepend">
<span class = "add-on"><i class = "icon-user"></i></span>
<input type = "text" class = "input-xlarge" id = "login_name" name = "login_name" placeholder = "Login name"><div id = "name_inspector"></div>
</div>
</div>
</div>
这是在文本字段的输入更改后做出反应的函数
$(document).ready(function(){
//$('#name_inspector').css('background-image', 'url(img/name-is-free.png)');
$("#login_name").change(
function()
{
$('#name_inspector').css('background-image', 'img/ajax-loader-arrows.gif');
$.get(
"is_usr_name_free.php?login_name="+$('#login_name').val(), {},
// At success.
function(data)
{
var style_arr = data.split('@');
alert(style_arr[0]+style_arr[1]);
$('#name_inspector').css(style_arr[0], style_arr[1]);
}, "html");
});
在 Firebug 样式设置正确并加载图片。但是,没有看到图片。