这里是完整的代码我使用但没有CSS,我只想运行这2个javascripts,任何人都可以发送我编辑的完整代码吗?
这是我的演示页面http://iscree.orgfree.com
这里我有jquery-1.4.2.js,但它们在指定页面中的两个代码都适用,而不是同一页面!
<script type="text/javascript" src="http://www.iscreen.orgfree.com/js/jquery-1.4.2.js"></script>
<style type="text/css">a {text-decoration: none}</style>
<!Here is js1---------->
<script type="text/javascript">//<![CDATA[
$(window).load(function(){
jQuery(document).ready(function(){
jQuery('#hideshow').live('click', function(event) {
jQuery('#content').toggle('show');
});
});
});//]]>
</script>
<!Here is js1---------->
<!Here is js2---------->
<script type='text/javascript'>//<![CDATA[
$(windows).load(function(){
// Optional code to hide all divs
$("div").hide();
// Show chosen div, and hide all others
$("input").click(function ()
{
$("#" + $(this).attr("class")).show().siblings('div').hide();
});
});//]]>
</script>
<!Here is js2---------->
<!Here example1---------->
Click a button to make it visible:<br /><br />
<input type="button" value="One" class="one" />
<input type="button" value="Two" class="two" />
<input type="button" value="Three" class="three" />
<input type="button" value="Four" class="four" /><br /><br />
<div id="one">One</div>
<div id="two">Two</div>
<div id="three">Three</div>
<div id="four">Four</div><br/><br/>
<!Here example1---------->
<!Here example2---------->
<a href="#" id='hideshow'>here</a>
<div id='content' class="content" style="display: none;">
<div id="container" style="width:300px">
<div id="title" style="background-color:#161616;">
<center><h1 style="margin-bottom: 0; color: white;">iScreen Desktop</h1></center>
</div>
<div id="row1left" style="background-color:#636262;height: 150px;width:150px;float:left;">
<center><a href="#" class="topopup">Some text</a></center>
</div>
<div id="row1right" style="background-color:#161616;color: white;height: 150px;width:150px;float:left;">
<p>Content goes here</p>
</div>
<div id="row2left" style="background-color:#636262;height: 60px;width:150px;float:left;">
<center><form name="tokey"><input type="text" name="key" onblur="if (this.value == '') {this.value = 'Kerko';}" onfocus="if(this.value == 'Kerko') {this.value = '';}" value="Kerko" size="10"><input type="button" onClick="ToKey()" value="Go"></form></center>
</div>
<div id="row2right" style="background-color:#161616;color: white;height: 55px;width:150px;float:left;">
<center><a href="logout.php"><img src="./users/desktop/img/shdown.png" height="19" width="19"> <font size="5" style="color: white">Shkyqu</font></a></center>
</div>
<div id="footer" style="background-color:#161616;color: white;clear:both;text-align:center;">
By SMKproduction.eu5.org</div>
</div>
</div>
<!Here example2---------->
答案 0 :(得分:0)
为什么你不把所有代码都放在同一个“准备好”的电话中?:
<script type="text/javascript">
$(document).ready(function(){
$('#hideshow').live('click', function(event) {
$('#content').toggle('show');
});
$("div").hide();
// Show chosen div, and hide all others
$("input").click(function ()
{
$("#" + $(this).attr("class")).show().siblings('div').hide();
});
});
</script>
请注意window.load和jQuery.ready具有相同的目的:在浏览器加载完文档时执行functio。你不需要他们两个......
答案 1 :(得分:0)
只需将它们放入document.ready
即可 $(document).ready(function () {
jQuery('#hideshow').live('click', function (event) {
jQuery('#content').toggle('show');
});
$("div").hide();
$("input").click(function () {
$("#" + $(this).attr("class")).show().siblings('div').hide();
});
});