< script type="text/javascript" src="/jquery/jquery.js" >< /script >
< html >
< head >
< script type="text/javascript" src="jquery.js" >< /script >
< script type="text/javascript" >
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
< /script>
< /head>
< body>
< h2>This is a heading< /h2>
< p>This is a paragraph.< /p>
< p>This is another paragraph.< /p>
< button type="button">Click me< /button>
< /body>
< /html>
< head>
< script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js">< /script>
< /head>
< head>
< script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js">< /script>
< /head>
$(document).ready(function(){
--- jQuery functions go here ----
});
元素。
$(".test").hide()
jQuery hide() 函数,隐藏所有 class="test" 的元素。
$("p").css("background-color","gray");
< html>
< head>
< script type="text/javascript" src="jquery.js">< /script>
< script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
< /script>
< /head>
< body>
< h2>This is a heading< /h2>
< p>This is a paragraph.< /p>
< p>This is another paragraph.< /p>
< button>Click me< /button>
< /body>
< /html>
$("button").click(function() {..some code... } )
$("p").hide();
< head>
< script type="text/javascript" src="jquery.js">< /script>
< script type="text/javascript" src="my_jquery_functions.js">< /script>
< /head>
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
$(selector).hide(speed,callback)
$(selector).show(speed,callback)
$("button").click(function(){
$("p").hide(1000);
});
$(selector).toggle(speed,callback)
$("button").click(function(){
$("p").toggle();
});
$(selector).slideDown(speed,callback)
$(selector).slideUp(speed,callback)
$(selector).slideToggle(speed,callback)
$(".flip").click(function(){
$(".panel").slideDown();
});
$(".flip").click(function(){
$(".panel").slideUp()
})
$(".flip").click(function(){
$(".panel").slideToggle();
});
$(selector).fadeIn(speed,callback)
$(selector).fadeOut(speed,callback)
$(selector).fadeTo(speed,opacity,callback)
$("button").click(function(){
$("div").fadeTo("slow",0.25);
});
$("button").click(function(){
$("div").fadeOut(4000);
});
$(selector).animate({params},[duration],[easing],[callback])
animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});
第二个参数是 duration。它定义用来应用到动画的时间。它设置的值是:"slow", "fast", "normal" 或毫秒。
< script type="text/javascript">
$(document).ready(function(){
$("#start").click(function(){
$("#box").animate({height:300},"slow");
$("#box").animate({width:300},"slow");
$("#box").animate({height:100},"slow");
$("#box").animate({width:100},"slow");
});
});
< /script>
< script type="text/javascript">
$(document).ready(function(){
$("#start").click(function(){
$("#box").animate({left:"100px"},"slow");
$("#box").animate({fontSize:"3em"},"slow");
});
});
< /script>
$("button").click(function(){
$("p").hide(1000);
});
$(selector).hide(speed,callback)
callback 参数是一个在 hide 操作完成后被执行的函数。
$("p").hide(1000);
alert("The paragraph is now hidden");
$("p").hide(1000,function(){
alert("The paragraph is now hidden");
});
$(selector).html(content);
html() 函数改变所匹配的 HTML 元素的内容(innerHTML)。$("p").html("W3C HTML");
$(selector).append(content)
append() 函数向所匹配的 HTML 元素内部追加内容。$(selector).prepend(content)
prepend() 函数向所匹配的 HTML 元素内部预置(Prepend)内容。$("p").append(" W3C HTML");
语法$(selector).after(content)
after() 函数在所有匹配的元素之后插入 HTML 内容。$(selector).before(content)
before() 函数在所有匹配的元素之前插入 HTML 内容。$("p").after(" W3C HTML.");
$(selector).css(name,value)
$("p").css("background-color","red");
$(selector).css({properties})
$("p").css({"background-color":"red","font-size":"200%"});
$(selector).css(name)
$(selector).css("background-color");
$(selector).height(value)
$("#id100").height("200px");
$(selector).width(value)
$("#id200").width("300px");
$(selector).load(url,data,callback)
请使用 selector 来定义要改变的 HTML 元素,使用 url 参数来指定数据的 web 地址。邮箱:1114853779@qq.com如有转载请注明出处
版权归个人所有