<a id="startMenu" href="#" class="more">
<section id="menu" class="right_menu disnone">
<dl>
<dt><i></i></dt>
<Dd>您好!创富金融欢迎您</Dd>
</dl>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">简介</a></li>
<li><a href="#">...</a></li>
<div style="clear:both;"></div>
</ul>
</section>
<script>
$(document).ready(function() {
$("#startMenu").click(function() {
if($("#menu").is(":visible")){
$("#menu").hide();
}else{
$("#menu").show();
}
});
});
</script>
$("button").click(function(){
$("p:first").addClass("intro");
});
$( "p" ).removeClass( "myClass yourClass" )
$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
<p>hello</p>
<p id="hello">hello</p>
<script type="text/javascript">
$("p").addClass("Helloworld");
$("#hello").addClass("Helloworld");
</script>
$(document).ready(function(){
setTimeout(function(){
$("#error").hide();
},3000);
});
<p>hello</p>
<p id="hello">hello</p>
<script type="text/javascript">
$("p").text("Helloworld");
$("#hello").text("Helloworld");
</script>
jQuery.ajax({
type:"GET",
url: "/path/to/url",
data: "code="+code,
success:function(data){
if(data.status){
alert(data.text)
}
},
error: function(){
}
});
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$.getJSON('http://www.foobar.com/json.php?callback=?', function(data){
alert(data.foo);
});
</script>
<?php
echo $_GET['callback'], '(', json_encode(array('foo' => 'bar')), ')';
?>
// Using YQL and JSONP
$.ajax({
url: "http://query.yahooapis.com/v1/public/yql",
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Tell YQL what we want and that we want JSON
data: {
q: "select title,abstract,url from search.news where query=\"cat\"",
format: "json"
},
// Work with the response
success: function( response ) {
console.log( response ); // server response
}
});
$(document).ready(function() {
$("#Button1").click(function() {
$("#Tab1").hide();
$("#Tab2").show();
});
$("#Button2").click(function() {
$("#Tab1").show();
$("#Tab2").hide();
});
});
解除事件绑定
$( "#Button1").unbind( "click" ); $( "#Button2").unbind( "click" );
事件中绑定事件
$("#Button").click(function() {
$( "#Button1").unbind( "click" );
$( "#Button2").unbind( "click" );
$("#Button1").click(function() {
$("#Tab1").hide();
$("#Tab2").show();
});
$("#Button2").click(function() {
$("#Tab1").show();
$("#Tab2").hide();
});
});