gpt4 book ai didi

jQuery ID 选择器不适用于 IE7 (.show()/.hide())

转载 作者:行者123 更新时间:2023-11-28 19:00:26 25 4
gpt4 key购买 nike

在加载 jQuery 时,我试图根据条件隐藏/显示某些 div。在 IE7 之外一切正常。我将其分解,发现以下类选择器起作用:

$('.medication_div').hide();

但是,我需要的 ID 选择器没有(注意:我尝试了硬代码值,但也没有用。

//Get the name of the medication selected
var medication_selected = $("ul#medication_classes li:last-child p").text();
//Show the div associated with the selected medication card
$("#"+medication_selected).show();

运行后生成的HTML代码如下:

<ul id="medication_classes">
<li>
<p>Celexa</p>
<input id="Meds_0" name="Meds[0]" type="hidden" value="Celexa" />
</li>

<li>
<p>Lisinopril</p>
<input id="Meds_1" name="Meds[1]" type="hidden" value="Lisinopril" />
</li>
</ul>
<div id="results_detail" class="grid_12 alpha">
<ul>
<li>

<div class="medication_div" id="Celexa">
<p id="class_trigger">Protocol Set Triggering: General<input id="Celexa_ProtocolSetID" name="Celexa[ProtocolSetID]" type="hidden" value="1" /></p><br>
<p class="left_input">Does the patient still have active refills for Celexa?</p>
<div class="right_input">No:<input id="Celexa_ActiveRefills_No" name="Celexa[ActiveRefills]" type="radio" value="No" /> Yes:<input id="Celexa_ActiveRefills_Yes" name="Celexa[ActiveRefills]" type="radio" value="Yes" /></div><br/>
<div class="clear"></div>
<div id="Celexa_notActive">
<p>Approve the Celexa refill as indicated in the patient record.</p>

</div>


<div id="Celexa_active">
<p class="left_input" id="dose_change">When was the dosage for this medication last changed?</p> <div class="right_input"><input class="date" id="Celexa_MedicationChangeDate" name="Celexa[MedicationChangeDate]" type="text" /></div><br/>
<div class="clear"></div>


<div class="table_header med_info">
<h5>Fill in the following as much possible in order to find the most relevant protocol.</h5>
</div>

<table width="846">
<tr id="labels">
<th width="33%">Name</th>
<th width="33%">Value</th>
<th width="33%">Result Date</th>
</tr>
<tr>
<td width="33%">Medication Start<input id="Celexa_TestResult_0_Name" name="Celexa[TestResult][0][Name]" type="hidden" value="Medication Start" />

</td>
<td width="33%">
<p>N/A</p>
</td>
<td width="33%">
<input class="date" id="Celexa_TestResult_0_Date" name="Celexa[TestResult][0][Date]" type="text" />
</td>
</tr>

</table>

<label>Note to physician about refill request:</label><textarea class="md_note" id="Celexa_Note" name="Celexa[Note]"></textarea>
</div>
</div>
</li>
<li>
<div class="medication_div" id="Lisinopril">
<p id="class_trigger">Protocol Set Triggering: Hypertension Medications<input id="Lisinopril_ProtocolSetID" name="Lisinopril[ProtocolSetID]" type="hidden" value="4" /></p><br>

<p class="left_input">Does the patient still have active refills for Lisinopril?</p>
<div class="right_input">No:<input id="Lisinopril_ActiveRefills_No" name="Lisinopril[ActiveRefills]" type="radio" value="No" /> Yes:<input id="Lisinopril_ActiveRefills_Yes" name="Lisinopril[ActiveRefills]" type="radio" value="Yes" /></div><br/>
<div class="clear"></div>
<div id="Lisinopril_notActive">
<p>Approve the Lisinopril refill as indicated in the patient record.</p>
</div>


<div id="Lisinopril_active">

<p class="left_input" id="dose_change">When was the dosage for this medication last changed?</p> <div class="right_input"><input class="date" id="Lisinopril_MedicationChangeDate" name="Lisinopril[MedicationChangeDate]" type="text" /></div><br/>
<div class="clear"></div>


<div class="table_header med_info">
<h5>Fill in the following as much possible in order to find the most relevant protocol.</h5>
</div>
<table width="846">
<tr id="labels">

<th width="33%">Name</th>
<th width="33%">Value</th>
<th width="33%">Result Date</th>
</tr>
<tr>
<td width="33%">Medication Start<input id="Lisinopril_TestResult_0_Name" name="Lisinopril[TestResult][0][Name]" type="hidden" value="Medication Start" />
</td>

<td width="33%">
<p>N/A</p>
</td>
<td width="33%">
<input class="date" id="Lisinopril_TestResult_0_Date" name="Lisinopril[TestResult][0][Date]" type="text" />
</td>
</tr>
<tr>

<td width="33%">Creatinine<input id="Lisinopril_TestResult_1_Name" name="Lisinopril[TestResult][1][Name]" type="hidden" value="Creatinine" />
</td>
<td width="33%">
<input id="Lisinopril_TestResult_1_Value" name="Lisinopril[TestResult][1][Value]" type="text" />
</td>
<td width="33%">
<input class="date" id="Lisinopril_TestResult_1_Date" name="Lisinopril[TestResult][1][Date]" type="text" />
</td>

</tr>
</table>

<label>Note to physician about refill request:</label><textarea class="md_note" id="Lisinopril_Note" name="Lisinopril[Note]"></textarea>
</div>
</div>
</li>
</ul>
</div>

当对上面的例子进行硬编码时,我已经硬编码无济于事了:

$("#Celexa").show();

有什么想法吗?

最佳答案

事实证明,Rails 代码生成了一个额外的字符,该字符只能在 IE7 中进行解释。到目前为止,我仍然不确定字符是什么(可能是非 unicode),但我通过使用 jQuery 通配符选择器解决了这个问题:

$("div[id^="+medication_selected+"]").show();

关于jQuery ID 选择器不适用于 IE7 (.show()/.hide()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6067216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com