時,這是一個完美的控制檯工作代碼:jQuery的控制檯工作,但不加載網站
jQuery(".cf7_wrap_com li").each(function(){
jQuery(this).find(".first_univer input").click(function(){
var label1 = jQuery(this).parent().find("label").html();
if(jQuery(this).is(":checked")) {
jQuery(this).parent().find(".first_high").show();
jQuery(".cf7_wrap_com li").not(jQuery(this).parent().parent()).each(function(){
jQuery(this).find(".first_high").hide();
});
}
else {}
});
});
和下面的代碼是什麼,我保存在我的自定義的js文件,而不是工作的網站負載
jQuery(document).ready(function($){
jQuery(window).bind("load", function() {
jQuery(".cf7_wrap_com li").each(function(){
jQuery(this).find(".first_univer input").click(function(){
var label1 = jQuery(this).parent().find("label").html();
if(jQuery(this).is(":checked")) {
jQuery(this).parent().find(".first_high").show();
jQuery(".cf7_wrap_com li").not(jQuery(this).parent().parent()).each(function(){
jQuery(this).find(".first_high").hide();
});
}
else {}
});
});
});
});
我也想知道是否有可能修剪此代碼,因爲我想我可能已經添加了一些不必要的東西。
我在兩個單選按鈕(默認情況下處於非活動狀態)上使用它,當用戶單擊其中任何一個按鈕時打開一個簡短的窗體。
以下是圖像:
這是html
:
<h1>What type of student?</h1>
<ul class="cf7_wrap_com first_use">
<li>
<div class="highschoolform first_univer"><input id="#school" name="School" type="radio" value="highschool" /> <label for="highschool">High School</label>
<div class="cf7_wrap_hs first_high">[contact-form-7 id="3552" title="High school"]</div>
</div>
</li>
<li>
<div class="unversityform first_univer"><input id="#University" name="School" type="radio" value="University" /> <label for="University">University</label>
<div class="cf7_wrap_uni first_high">[contact-form-7 id="3553" title="University"]</div>
</div>
</li>
</ul>
您是否收到任何錯誤消息在開發者控制檯?什麼是你的HTML - 你是在需要jQuery的腳本之前加載jQuery? –
我剛剛發佈了HTML。我在開發中沒有收到任何錯誤消息。安慰。爲了在腳本之後加載它,我添加了加載函數(可能這是我做錯的地方) – Rahul
你有包括jquery嗎? –