我寫了一個wordpress插件,打印主流,當用戶點擊主流時,它切換屬於主流的主題。但是,它適用於前端。javascript click event does not respond
我想在wordpress後端實現這一點。 除了切換功能外,每件事情都可以使用。
我已經在WordPress的管理頭文件中包含jquery。
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// dynamically handlling main streams and their subjects
// when a main stream is selected, it is sub categories(subjects) div will
// be toggle.
// alert(subClicked);
$(".main_stream").click(function() {
var subClicked = $(this).attr('id');
// $(".stream").hide();
// alert(subClicked);
console.log("value is "+subClicked);
$("#" + subClicked + "sub").toggle();
});
});
</script>
我嘗試用firbug調試,雖然當我點擊的主流,它並不去$(".main_stream").click(function()
。沒有什麼改變。
我錯過了什麼,我是新的WordPress的。我不知道jQuery是如何處理WordPress的管理面板。任何人都可以給我一個提示嗎?的
部分生成的HTML
<div id="Statisticssub" class="hide" "="" style="padding-left: 20px;">
<input type="checkbox" id="Technology_Solutions" value="" class="main_stream" checked="checked"/>
Technology Solutions
<br/>
<div id="Technology_Solutionssub" class="hide" style="display: block;" "="">
<div style="width: 350px; height: 30px; padding-top: 5px;">
<div style="width: 350px; height: 20px; padding-top: 5px;">
<div style="width: 260px; float: left; padding-top: 5px;">
<input type="checkbox" id="16" name="check_subjects[]"/>
C#
</div>
<div style="width: 75px; height: 10px; float: left; padding-right: 15px;">
</div>
<div style="width: 350px; height: 20px; padding-top: 5px;">
<div style="width: 260px; float: left; padding-top: 5px;">
<div style="width: 75px; height: 10px; float: left; padding-right: 15px;">
</div>
爲什麼包含'jQuery'的兩個版本。只保留其中一個 –
我刪除了'' – wordpressm
是'.main_stream'動態添加的嗎? –