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

jQuery ID选择器不适用于IE7(.show()/.hide()),jquery,html,css,internet-explorer,Jquery,Html,Css,Internet Explorer,在jQuery加载时,我试图根据条件隐藏/显示某些div。在IE7之外一切都正常。我将其分解,发现以下类选择器可以工作: 但是,我需要的ID选择器却没有(注意:我尝试了对代码值进行加密,但也没有成功 //Get the name of the medication selected var medication_selected = $("ul#medication_classes li:last-child p").text(); //Show the div associated with

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

但是,我需要的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>
有什么想法吗?

在我的ie7上运行得很好。 在firefox中检查css/样式

顺便说一句-尝试使用json、模板和jquery数据以获得更好的结果。例如:

HTML:

选择一个:

协议集触发:常规

患者是否仍在积极补充Celexa?

否:是:

批准患者记录中所示的Celexa补液

这种药物上次的剂量是什么时候改变的?

尽可能填写以下内容,以找到最相关的协议

JS:

$(函数(){
风险值=[
{名称:'Celexa',协议:'General'},
{名称:'赖诺普利',方案:'高血压药物'}
];
for(药物中的var medicationID){
var药物=药物[药物ID];
$(“
  • ”) .数据('medicineData',药物) .text(药物名称) .appendTo(“#药物类”) 。单击(函数(){ var medicineData=$(this.data('medicineData'); $('.data name').text(medicineData.name); $('data protocol').text(medicineData.protocol); }); } });
  • 也许可以使用纯-这是一个很好的模板引擎。

    在我的ie7上运行得很好。 在firefox中检查css/样式

    顺便说一句-尝试使用json、模板和jquery数据以获得更好的结果。例如:

    HTML:

    选择一个:

    协议集触发:常规

    患者是否仍在积极补充Celexa?

    否:是:

    批准患者记录中所示的Celexa补液

    这种药物上次的剂量是什么时候改变的?

    尽可能填写以下内容,以找到最相关的协议

    JS:

    $(函数(){
    风险值=[
    {名称:'Celexa',协议:'General'},
    {名称:'赖诺普利',方案:'高血压药物'}
    ];
    for(药物中的var medicationID){
    var药物=药物[药物ID];
    $(“
  • ”) .数据('medicineData',药物) .text(药物名称) .appendTo(“#药物类”) 。单击(函数(){ var medicineData=$(this.data('medicineData'); $('.data name').text(medicineData.name); $('data protocol').text(medicineData.protocol); }); } });

  • 可能使用pure-这是一个很好的模板引擎。

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

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

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

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

    嗯……你能在你的IE版本上看一下现场吗?在第一个屏幕上输入两个med“Lisnopril”和“Celexa”。在下一页,卡片下面的med div将显示在Firefox中,但不会显示在IE7中(至少是我的)。对于IE第一个屏幕上的
  • bug的任何提示,我们都将不胜感激:)(流程的第二阶段)所有的药物都标记为“准备发布”嗯……你能在你的IE版本上看一下现场网站吗?在第一个屏幕上输入两种药物“赖诺普利”和“塞莱克斯”。在下一页,卡片下面的医学div将显示在Firefox中,但不会显示在IE7中(至少我的))在ie(过程的第二阶段)中,所有药物都标有“准备出版”字样
    <p>select one:</p>
    <ul id="medication_classes">
    </ul>
     <div id="medication_detail">
    <p>Protocol Set Triggering: <span class="data-protocol">General</span></p>
    <p>Does the patient still have active refills for <span class="data-name">Celexa</span>?</p> 
    <p>No:<input type="radio" value="No" />  Yes:<input type="radio" value="Yes" /></p>
    <p>Approve the <span class="data-name">Celexa</span> refill as indicated in the patient record.</p>
    <p>When was the dosage for this medication last changed?</p> 
    <p><input class="date" /></p>
    <p>Fill in the following as much possible in order to find the most relevant protocol.</p>
    
    $(function () {
            var medications = [
                { name: 'Celexa', protocol: 'General' },
                { name: 'Lisinopril ', protocol: 'Hypertension Medications' }
            ];
    
    
            for (var medicationID in medications) {
                var medication = medications[medicationID];
    
                $('<li>')
                    .data('medicineData', medication)
                    .text(medication.name)
                    .appendTo('#medication_classes')
                    .click(function () {
                        var medicineData = $(this).data('medicineData');
                        $('.data-name').text(medicineData.name);
                        $('.data-protocol').text(medicineData.protocol);
                    });
            }
    
        });
    
    $("div[id^="+medication_selected+"]").show();