我正在尝试从外部文件访问 jQuery,但它在我的页面上不起作用。我检查了我的代码并在互联网上搜索但没有发现我的错误......
clearableformfield.jsp
<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="JQuery/jquery.clearable.js"></script>
<link rel="stylesheet" href="JQuery/jquery.clearable.css" type="text/css" />
</head>
<body>
<div id="dom">
<input type="text" class="foo"></input>
</div>
<script>
$(document).ready(function() {
$('.foo').clearable();
});</script>
</body>
</html>
jquery.clearable.js
$(this).css({'border-width': '0px', 'outline': 'none'})
.wrap('<div id="sq" class="divclearable"></div>')
.parent()
.attr('class', $(this).attr('class') + ' divclearable')
.append('<a class="clearlink" href="javascript:"></a>');
$('.clearlink')
.attr('title', 'Click to clear this textbox')
.click(function() {
$(this).prev().val('').focus();
});
jquery.clearable.css
.divclearable {
border: 1px solid #888;
display: -moz-inline-stack;
display: inline-block;
zoom:1;
*display:inline;
padding-right:5px;
vertical-align:middle;
}
a.clearlink {
background: url("close-button.png") no-repeat scroll 0 0 transparent;
background-position: center center;
cursor: pointer;
display: -moz-inline-stack;
display: inline-block;
zoom:1;
*display:inline;
height: 12px;
width: 12px;
z-index: 2000;
border: 0px solid;
}
#dom{
background-color:#b0c4de;}
}
所有这些文件都在 JQuery 文件夹中的 web 内容中