gpt4 book ai didi

javascript - Jquery .show() 和 .hide() 甚至 .css( {"display":"none"});不在火狐浏览器中工作?

转载 作者:行者123 更新时间:2023-11-30 23:47:16 24 4
gpt4 key购买 nike

出于某种奇怪的原因,我的脚本中显示和隐藏对象的部分似乎不起作用。我不确定是否是 Firefox 不喜欢这样,或者是否是我拥有的基于函数的代码(以节省重复的代码行)?

有一个工作示例 here javascript 是 here

** 这是 jquery **

$(document).ready(function(){

totUpPrices();
checkBedType();
checkHeadboardOption();

$('.bedtype_price').click(function()
{
checkBedType();
});

$('.headboard_option').click(function()
{
checkHeadboardOption();
});

$('#bed-floater').scrollFollow({ offset:10 });
$('.texture').click(function()
{

$('.texture').removeClass("checked");
$('.texture').children("input").attr("checked","");

$(this).addClass("checked");
$(this).children("input").attr("checked","checked");

});

$('.pricechanger_auto').change(function()
{
totUpPrices();
});

$('.bed-width-single').change(function()
{
if($(this).val()=="2' 6\"" || $(this).val()=="3'")
{
$('.pocketmatic-mattress').attr("disabled","");
}
else
{
$('.pocketmatic-mattress').attr("disabled","disabled");
if($('.pocketmatic-mattress').parent("select").val()=="Pocketmatic")
{
$('.pocketmatic-mattress').parent("select").children("option[value='']").attr("selected","selected");
}
}
});

$('.bed-width-twin').change(function()
{
if($(this).val()=="4' 6\"" || $(this).val()=="6'")
{
$('.pocketmatic-mattress').attr("disabled","");
}
else
{
$('.pocketmatic-mattress').attr("disabled","disabled");
if($('.pocketmatic-mattress').parent("select").val()=="Pocketmatic")
{
$('.pocketmatic-mattress').parent("select").children("option[value='']").attr("selected","selected");
}
}
});

function totUpPrices()
{

var totalprice = 0;

// Check Type of bed prices
var objs = $('.bedtype_price');
$.each(objs, function(index, value) {

if($(value).attr("checked"))
{
totalprice = totalprice + parseInt($(value).attr("cost"));
}

});

// Check Delivery Options
var objs = $('.deliveryoptions_price');
$.each(objs, function(index, value) {

if($(value).attr("checked"))
{
totalprice = totalprice + parseInt($(value).attr("cost"));
}

});

// Check Dropdown Prices
var objs = $('.select_price');
$.each(objs, function(index, value) {

newvalue = $(value).attr("value");
$.each($(value).children("option"), function(i, l){
if($(this).attr("value")==newvalue)
{
totalprice = totalprice + parseInt($(this).attr("cost"));
}

});

});
$('#totalincvat').text(totalprice);
}

function checkBedType()
{
var objs = $('.bedtype_price');
var checkedType = '';
$.each(objs, function(index, value) {

if($(value).attr("checked"))
{
checkedType = $(value).val();
}

});
if(checkedType == "Single Bed")
{
$('.show_with_single').show();
$('.show_with_twin').hide();
$('.changeOnTwin').text("Would you like a headboard?");
}
else
{
$('.show_with_twin').show();
$('.show_with_single').hide();
$('.changeOnTwin').text("Would you like headboards?");
}
}

function checkHeadboardOption()
{
var objs = $('.headboard_option');
var checkedType = '';
$.each(objs, function(index, value) {

if($(value).attr("checked"))
{
checkedType = $(value).val();
}

});
if(checkedType == "Yes")
{
$('.headboard-options').show();
}
else
{
$('.headboard-options').hide();
}
}

});

感谢所有帮助

最佳答案

您的 HTML 未通过验证。请参阅此处,

http://validator.w3.org/check?uri=http%3A%2F%2Fbed-adjustable.co.uk%2Fbuild-a-bed%2F&charset=%28detect+automatically%29&doctype=Inline&group=0

您的 html 的第一行已经无效。

抱歉,你的第一行没问题,我不知道那是 HTML5,尽管现在做 HTML5 还为时过早。

关于javascript - Jquery .show() 和 .hide() 甚至 .css( {"display":"none"});不在火狐浏览器中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2644109/

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