在尝试为我的站点找到一种选择多个按钮的方法后,我发现jquery 1.8文件就能做到这一点。作为编程和学习python和django的新手,我还没有深入研究javascript的世界。但是到目前为止,我得到的是,你可以将这些jquery文件合并到你的html中,而不需要在服务器端做任何事情。毕竟,在这种情况下,我只是想让我的按钮做一些事情。
现在,当我双击html文件时,jquery脚本可以工作,但当我通过我的应用程序运行html文件时,它就不起作用了。因此,它让我相信,当运行我的应用程序时,我必须在服务器端做一些事情才能让它工作。
这有意义吗?
有问题的Html代码,我没有在视图文件中修饰任何东西。
<link rel="stylesheet" href="/home/jamie//Downloads/jquery-ui-1.8.10/themes/base/jquery.ui.all.css">
<script src="/home/jamie/Downloads/jquery-ui-1.8.10/jquery-1.4.4.js"></script>
<script src="/home/jamie/Downloads/jquery-ui-1.8.10/ui/jquery.ui.core.js"></script>
<script src="/home/jamie/Downloads/jquery-ui-1.8.10/ui/jquery.ui.widget.js"> </script>
<script src="/home/jamie/Downloads/jquery-ui-1.8.10/ui/jquery.ui.button.js"></script>
<link rel="stylesheet" href="/home/jamie/Downloads/jquery-ui-1.8.10/demos/demos.css">
<script>
$(function() {
$( "#check" ).button();
$( "#format" ).buttonset();
});
</script>
<style type="text/css">
table.ranking {position: absolute; top: 351; left: 450; }
ul {position: absolute; top: 400; left: 200; }
format { margin-top: 2em; }
</style>
<div class="demo">
<input type="checkbox" id="check" /><label for="check">Toggle</label>
<div id="format">
<input type="checkbox" id="check1" /><label for="check1"> SQ </label>
<input type="checkbox" id="check2" /><label for="check2"> DL </label>
<input type="checkbox" id="check3" /><label for="check3"> BP </label>
<input type="checkbox" id="check4" /><label for="check4"> Snatch </label>
<input type="checkbox" id="check5" /><label for="check5"> CJ </label>
</div>
</div>发布于 2011-10-10 22:12:02
我怀疑您的各种jQuery文件的路径(在您的标签中)只对您的本地副本有效,而不是您上传的副本。
尝试使用Google Code versions,它可以在任何地方工作(只要您的浏览器在线):
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css" />(有关如何访问其他CSS主题的信息,请参阅here。)
发布于 2011-10-11 15:36:20
如果您想通过选择/取消选择"Toggle“来选择或取消选择所有复选框,请尝试以下操作:
$(document).ready(function(){
var checked = true;
$('#check').click(function(){
if (checked) {
$("#format input[type=checkbox]").attr('checked',true);
checked = false;
} else {
$("#format input[type=checkbox]").attr('checked',false);
checked = true;
}
});
}); https://stackoverflow.com/questions/7712989
复制相似问题