首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JQuery自动完成主题框未正确放置

JQuery自动完成主题框未正确放置
EN

Stack Overflow用户
提问于 2012-09-21 05:44:26
回答 1查看 176关注 0票数 0

所以我正在试验JQuery的主题,我对它的位置有一些问题。在没有添加从网站下载的jquery自定义主题的情况下,自动完成框加载到文本框下面(见图1),当我加载样式表(为了去掉项目符号列表)时,它会加载窗口左上角的文本框。代码如下:我添加的样式表:<link href="style/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />

我向其中添加样式表的代码:

代码语言:javascript
复制
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>

<script>
$(document).ready(function(){
    var drugs = ["Acepromazine (PromAce, Aceproject)", "Acetaminophen (Tylenol)",
        "Acetazolamide (Diamox, Dazamide)", "Acetylcysteine (Mucomyst)", 
        "Acetylsalicylic Acid (Aspirin)", 
        "Activated Charcoal (Toxiban, Liqui-Char, UAA Gel)", "Acyclovir (Zovirax)",
        "Albuterol (Proventil, Volmax, Ventolin)", "Allopurinol (Zyloprim)",
        "Alprazolam (Xanax)", "Amikacin (Amiglyde-V)", "Aminopentamide (Centrine)",
"Aminophylline",
"Amitraz (Mitaban, Preventic)",
"Amitriptyline HCl (Elavil)",
"Amlodipine Besylate (Norvasc)",
"Amoxicillin",
"Amoxicillin and Clavulanate (Clavamox)",
"Amphetamines",
"Amphotericin B",
"Ampicillin (Polyflex)",
"Antibiotic with Steroid Eye Medication",
"Apomorphine",
"Bismuth Subsalicylate (Pepto-Bismol)",
"Brinzolamide (Azopt)",
"Bromides",
"Buprenorphine (Buprenex)",
"Burow's Solution",
"Buspirone HCl (BuSpar)",
"Butorphanol Tartrate (Torbugesic, Torbutrol)",
"Calcitonin",
"Calcitriol (Vitamin D)",
"Calcium Gluconate",
"CAPSTAR (Nitenpyram)",
"Captopril (Capoten)",
"Carbamazepine (Tegretol)",
"Carboplatin (Paraplatin)",
"Carnitine (Carnitor)",
"Carprofen (Rimadyl)",
"Cefadroxil (Cefa-Tabs and Cefa-Drops)",
"Cefazolin (Kefzol, Ancef)",
"Cefixime (Suprax)",
"Cefotaxime (Claforan)",
"Cefotixin (Mefoxin)",
"Cefpodoxime Proxetil (Simplicef)",
"Ceftriaxone (Rocephin)",
"Cephalexin (Keflex)",
"Cephalothin",
"Chlorambucil (Leukeran)",
"Chloramphenicol (Chloromycetin)",
"Chlorhexidine",
"Chlorpheniramine Maleate (Chlor-Trimeton)",
"Chlorpromazine (Thorazine)",
"Cimetidine HCl (Tagamet)",
"Ciprofloxacin (Cipro, Ciloxan)",
"Cisplatin (Platinol-AQ)",
"Colchicine",
"Cyclophosphamide (Cytoxan, Neosar)",
"Cyclosporine (Atopica, Optimmune)",
"Cyclosporine Ophthalmic (Optimmune)",
"Cytarabine",
"Deracoxib (Deramaxx)",
"Derm Caps",
"Desmopressin (DDAVP)",
"Desoxycorticosterone (Percorten-V)",
"Dexamethasone"];
$("#drug_name_1").autocomplete({source:drugs});
});
</script>

<script type="text/javascript">

function addTreatment(){
}

function removeTreatment(){
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <input type="button" name="increase" id="increase" value="Increase Drug Treatments" onclick="addTreatment()"/>
  <input type="button" name="decrease" id="decrease" value="Decrease Drug Treatments" onclick="removeTreatment()"/>
</form>
<form id="add_drugs" name="add_drugs" method="post" action="">
    <table width="100%" border="1" name="drug_treatment_table" id="drug_treatment_table">
          <tr>
            <th width="3%" scope="col">#</th>
            <th width="14%" scope="col">Drug</th>
            <th width="32%" scope="col">Special Directions </th>
            <th width="18%" scope="col">Quantity</th>
            <th width="12%" scope="col">How Often</th>
            <th width="8%" scope="col">Starting</th>
            <th width="13%" scope="col">Finishing</th>
          </tr>
          <tr>
            <td>1</td>
            <td>
            <input type="text" name="drug_name_1" id="drug_name_1" /></td>
            </tr>
         </table>
    </form>
    </body>
    </html>

图片如下:

有人知道如何让自动完成文本框出现在正确的位置吗?

谢谢!琼恩

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-21 06:03:10

我一直在使用它,从来没有遇到过任何问题。虽然我使用的是不同的版本(我怀疑您的jquery ui和jquery ui主题的版本不兼容,但您的js似乎很旧):

代码语言:javascript
复制
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>

您还需要jquery ui主题,虽然我还没有检查它是否有效,但您似乎已经有了它。我一般使用ui-lightness主题,一切都很好。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12521384

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档