我是初学者,希望得到一些帮助,看看我犯了什么错误。我调整了“查找价格”两个按钮的链接。 “私人派对”。我尝试在形式上调整一些id,但没有运气。我有一些帮助开发javascript,现在我想做出改变,我遇到了一些麻烦。我花了好几个小时试图解决它仍然没有运气。
按钮中的链接目前会转到两个不同的php页面,需要对其进行调整,以便我可以将页面上的链接转到不同的php页面。
如果对如何解决我的问题有任何建议,我们将不胜感激。
请不要以负面评论撕开这个帖子,我刚开始自学编码并需要一些帮助/建议。感谢
我发布了一张图片,其中包含代码
JS:
var selectedGB;
var selectedCarrier;
var displayCarrier;
$(document).ready(function() {
$('.home-rt').hide();
$('.gb-button').each(function() {
$(this).click(function() {
$('.gb-button').removeClass('gb-button-selected');
console.log($(this).val());
selectedGB = $(this).val().slice(0,-2);
$(this).addClass('gb-button-selected');
updateCDisplay();
});
});
$('.carrier-button').each(function() {
$(this).click(function() {
$('.carrier-button').removeClass('carrier-button-selected');
$('.home-rt').hide();
if ( $(this).hasClass('carrier-ATT') ) {
selectedCarrier = 'ATT';
} else if ( $(this).hasClass('carrier-Sprint') ) {
selectedCarrier = 'Sprint';
} else if ( $(this).hasClass('carrier-Verizon') ) {
selectedCarrier = 'Verizon';
} else if ( $(this).hasClass('carrier-Rogers') ) {
selectedCarrier = 'Rogers';
} else if ( $(this).hasClass('carrier-Fido') ) {
selectedCarrier = 'Fido';
} else if ( $(this).hasClass('carrier-Cricket') ) {
selectedCarrier = 'Cricket';
} else if ( $(this).hasClass('carrier-Unlocked') ) {
selectedCarrier = 'Unlocked';
} else if ( $(this).hasClass('carrier-T-Mobile') ) {
selectedCarrier = 'TMobile';
} else if ( $(this).hasClass('carrier-Wi-Fi') ) {
selectedCarrier = 'WiFi';
} else {
selectedCarrier = 'Other';
}
if (selectedCarrier == "ATT") {
displayCarrier = "AT&T";
} else {
displayCarrier = selectedCarrier;
}
$(this).addClass('carrier-button-selected');
updateCDisplay();
});
$('.price-button').each(function() {
$(this).click(function() {
$('.price-button').removeClass('price-button-selected');
selectedPrice = $(this).val();
$(this).addClass('price-button-selected');
updateCDisplay();
});
});
});
});
function updateCDisplay() {
$('.home-rt').hide();
if (selectedCarrier){
$("#deviceLink").attr("href", "/sell/price/"+device+"/"+model+"/"+selectedCarrier+"/"+selectedGB);
$("#deviceText").attr("href", "/sell/price/"+device+"/"+model+"/"+selectedCarrier+"/"+selectedGB);
$("#deviceText").html(device + " " + model + "<br/>" + selectedGB + "GB" + " " + displayCarrier);
$("#dealer").attr("action", "/sell/price/"+device+"/"+model+"/"+selectedCarrier+"/"+selectedGB);
$("#private").attr("action", "/sell/private/"+device+"/"+model+"/"+selectedCarrier+"/"+selectedGB);
$("#displayImage").attr("src", "images/specs_"+device+"_"+model+".jpg");
$(".selectedView").show();
}
}
代码:
<div class="container" style="margin-top:-10px;margin-bottom:20px">
<div class="content">
<div class="content-inner">
<div id="splash">
<h4>Select your Blackberry q10</h4>
<div style="margin-top:18px; width:100%;min-height:350px;">
<div>
<div class="clear"></div>
<div style="text-align:center;margin:10px 0 20px 0;"><!---<img src="/images/test.jpg"/>-->
<div style="font-size:16px">Choose Your Carrier:</div>
<div><!--<input class="carrier-button carrier-all carrier-button-selected " type="button">--><input class="carrier-button carrier-ATT" type="button" /> <input class="carrier-button carrier-Verizon" type="button" /><input class="carrier-button carrier-T-Mobile" type="button" /> <input class="carrier-button carrier-Unlocked" type="button" /></div>
</div>
<div style="text-align:center;margin:10px 0 20px 0;">
</div>
<script>
var device = "Blackberry";
var model = "q10";
</script><script type="text/javascript" src="js/otherspecs.js"></script>
<div class="selectedView" style="margin-left: auto;margin-right: auto; width:35%; opacity: 0.980668; display:none;">
<div style="height:200px; text-align:center; float:left; display:table;">
<div style="display:table-cell; vertical-align:middle;">
<form action="" id="dealer"><input class="price-button" title="Compare different company quotes" type="submit" value="Find Prices" /></form>
<form action="" id="private"><input class="price-button" title="Sell it independently" type="submit" value="Private Party" /></form>
</div>
</div>
<div style="float:right;">
<div class="recent-trade-img" style="margin:10px 0 0 0;"><a href="" id="deviceLink"><img id="displayImage" src="" /></a></div>
<div class="name" style="margin:10px 0 0 0; text-align:center;"></div>
</div>
</div>