【问题标题】:Problems with 2 different jquery scripts in safari, chrome, webkit browserssafari、chrome、webkit 浏览器中 2 个不同 jquery 脚本的问题
【发布时间】:2013-01-18 21:39:27
【问题描述】:

首先我会说我没有编写这段代码,因为 jquery 并不是我真正的强项。我在 webkit 浏览器中的几个脚本遇到了一些问题,想知道是否有人可以帮助我。有问题的网站可以在http://disalle.dev.activemls.com查看。

问题 #1 等高 div:
我正在使用以下代码,然后分配如下 id="leftcol" class="equal-height" 和 id="maincol" class="equal-height"。使用以下内容,该脚本似乎只是定期工作:

<!--JQUERY EQUAL COLUMN HEIGHT-->
function resetHeight() {
   var maxHeight = 0;
   $(".equal-height").height("auto").each(function(){ 
       maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight; 
   }).height(maxHeight);
}
resetHeight();
// reset height on resize of the window:
$(window).resize(function() { 
    resetHeight();
});

问题 #2 动态选择选项值:
以下代码用于根据在选择框中选择的内容来选择在多选框中显示哪组选项值。首次加载页面时,选择框中的默认选项是“选择一个州”,选项是“ohio”或“michigan”。在默认状态下,css 设置为在选择框中隐藏 .ohio 和 .michigan 内容,然后应在选择时显示。这在 Firefox 中完美运行,但在 webkit 浏览器中再次失败。代码如下:

jQuery

<!--JQUERY DYNAMIC SELECT BOX-->
$('.area-select').change(function(){
    var selected = $(this).find(':selected');
    $('.area-list').hide();
   $('.'+selected.val()).show(); 
    $('.optionvalue').html(selected.html());
});

HTML

<div class="spacer">
                        <label>Select A State</label><br />
                            <select class="area-select">
                                <option selected="selected" value="start">Select A State...</option>
                                <option value="ohio">Ohio</option>
                                <option value="michigan">Michigan</option>
                            </select>
                    </div>
                    <div class="spacer">
                        <label>Select An Area</label><br />
                            <select name="area" size="10" multiple="multiple">
                                <option class="area-list start" value="start">Select A State First...</option>
                                <!-- TMPL_LOOP Area_descs -->
                                <option class="area-list ohio" value="<!-- TMPL_VAR area_name -->">
                                <!-- TMPL_VAR area_name -->
                                </option>
                                <!-- /TMPL_LOOP -->
                                <!-- TMPL_LOOP Area_descs -->
                                <option class="area-list michigan" value="<!-- TMPL_VAR area_name -->">
                                <!-- TMPL_VAR area_name -->
                                </option>
                                <!-- /TMPL_LOOP -->
                            </select>
                    </div>

CSS

.ohio, .michigan {display:none;}

提前感谢您的帮助!

【问题讨论】:

    标签: jquery google-chrome safari webkit


    【解决方案1】:

    你是如何加载 jQuery 等列脚本的?

    如果您使用的是$(document).ready(function(),那么您应该尝试使用$(window).load(function()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多