我有一組可點擊的圖片,它指定了特定的服務提供,當用戶點擊圖片時,與該服務相關的表單滑入框架。 - 部分和後續部分通過可點擊的div進行訪問(如'CONTINUE'按鈕)。所有表單都以'Step1'開頭,隨後的部分根據所選的服務而有所不同 。根據所選擇的服務「繼續按鈕」的.click (function()
使用jQuery更改.click(function(){元素使用jQuery的元素
這裏的HTML:
<div class="form-holder">
<form id="inquiry" action="" method="" enctype="multipart/form-data">
<div class="select">
<p>Please select a service from the options below:</p>
<div id="service1"><img class="product_img" src="" alt=" " />
<h1 style="margin-top: 0px">SERVICE ONE</h1></div>
<div id="service2"><img class="product_img" src="" alt="" />
<h1>SERVICE TWO</h1></div>
</div><!--End Select-->
<div id="step1">
<fieldset id="field1">
<legend>Contact Information</legend>
<div class="inline">
<div> Company Name:<br />
<input name="Company Name" size="20" type="text" /></div>
<div>Contact Person: <br />
<input name="Contact Person" size="20" type="text" /></div>
<div> Title/Affiliation: <br />
<input name="Affiliation" size="20" type="text" /></div></div>
</fieldset>
<div id="next1" class="next1">CONTINUE</div>
</div><!--End Step1-->
<div id="step2">
<fieldset>
<legend>Company Information</legend>
<div class="inline2">
<div> Products/Services:<br />
<textarea id="inline" name="Products"></textarea></div>
<div> Affiliations/Licensing: <br />
<textarea id="inline" name="Licenses"></textarea></div></div>
</fieldset>
<div class="next2">CONTINUE</div>
</div><!--End Step2-->
<div id="step3">
<fieldset>
<legend>Design Goals</legend>
<div class="inline2">
<div>
<textarea id="inline" name="Examples"></textarea></div>
<div>
<textarea id="inline" name="Features"></textarea></div></div>
<div>Additional Information :<br />
<textarea id="full" name="Comments"></textarea></div>
</fieldset>
<input id="send" type="submit" value="Sumit Query"><input type="reset" value="Clear" style="margin-left: 490px" />
</div><!--End Step3-->
</form>
而這裏的jQuery的:
$(document).ready(function() {
$("#service1").click(function() {
$(".select").animate({width:"0%"}, 1000);
$("#step1").animate({width:"77%"}, 1000);
});
});
$(document).ready(function() {
$(".next1").click(function() {
$("#step1").animate({width:"0%"}, 1000);
$("#step2").animate({width:"77%"}, 1000);
});
});
$(document).ready(function() {
$("#service2").click(function() {
$(".select").animate({width:"0%"}, 1000);
$("#step1").animate({width:"77%"}, 1000);
$("#next1").addClass('next2').removeClass('next1');
});
});
$(document).ready(function() {
$(".next2").click(function() {
$("#step1").animate({width:"0%"}, 1000);
$("#step3").animate({width:"77%"}, 1000);
});
});
的目標是當選擇"#service2"
更改類的"#next1"
所以它將動畫形式的#第3步,而不是"#step2"
。
這可能嗎?
我對jQuery相當陌生,可以使用我可以獲得的所有幫助。預先感謝您提供的任何幫助。
兆焦耳
它還有助於指定你跑什麼路障到讓別人做不必須通讀所有的t帽子代碼和打鼴鼠。 –
首先,你可以包含在一個單一的'$(文件)你的代碼。就緒(函數(){...});'塊 – ManseUK