var s={"a":"1","b":"2","c":"3"};
$(function(){
$.each(s,function(m,n){
$("ul").append("<li>"+m+":"+n+"</li>")}})
var s1=[
{"name":"a","age":"1"},
{"name":"b","age":"2"},
{"name":"c","age":"3"}];
$(function(){
$.each(s1,function(j){
$("ul").append("<li>"+s1[j].name+":"+s1[j].age+"</li>")})})
这两种方式都可以
$(function(){
$.each(s,function(m,n){
$("ul").append("<li>"+m+":"+n+"</li>")}})
var s1=[
{"name":"a","age":"1"},
{"name":"b","age":"2"},
{"name":"c","age":"3"}];
$(function(){
$.each(s1,function(j){
$("ul").append("<li>"+s1[j].name+":"+s1[j].age+"</li>")})})
这两种方式都可以
这是w3上的小例子,特意搜了下,第二个确实有引号,attr()的用法很多,attr("属性名","属性值");是其中之一,不明白楼下说true不应该加""为什么那么多赞。
$("button").click(function(){
$("img").attr("width","180");
});
$("button").click(function(){
$("img").attr("width","180");
});
2015-08-04
one()方法可以绑定元素任何有效的事件,但这种方法绑定的事件只会触发一次,它的调用格式如下:
$(selector).one(event,[data],fun)
参数event为事件名称,data为触发事件时携带的数据,fun为触发该事件时执行的函数。
$(selector).one(event,[data],fun)
参数event为事件名称,data为触发事件时携带的数据,fun为触发该事件时执行的函数。
2015-08-04
<script type="text/javascript">
$(function(){
$("#btnShow").bind("click",function(){
var $this = $(this);
$("ul").html("<img src='Images/Loading.gif' alt=''/>").load ("http://www.imooc.com/data/fruit_part.html li",function(){$this.attr("disabled", "true");});
})
});
</script>
$(function(){
$("#btnShow").bind("click",function(){
var $this = $(this);
$("ul").html("<img src='Images/Loading.gif' alt=''/>").load ("http://www.imooc.com/data/fruit_part.html li",function(){$this.attr("disabled", "true");});
})
});
</script>
2015-08-04
调用名为$.trim的工具函数,能删除字符串中左右两边的空格符,但该函数不能删除字符串中间的空格,调用格式为:
$.trim (str);
参数str表示需要删除左右两边空格符的字符串。
$.trim (str);
参数str表示需要删除左右两边空格符的字符串。
2015-08-04
<h3>hover()方法切换事件</h3>
<div>别走!你就是土豪</div>
<script type="text/javascript">
$(function () {
?(
function () {
<div>别走!你就是土豪</div>
<script type="text/javascript">
$(function () {
?(
function () {
2015-08-04
$(function () {
$("#name").tooltip({
show: {
effect: "slideDown",
delay: 350
},
hide: {
effect: "explode",
delay: 350
},
position: {
my: "left top",
at: "left bottom"
}
});
});
$("#name").tooltip({
show: {
effect: "slideDown",
delay: 350
},
hide: {
effect: "explode",
delay: 350
},
position: {
my: "left top",
at: "left bottom"
}
});
});
2015-08-04
<label style="border:solid 5px red"></label>
<script type="text/javascript">
$("div>label").css("border", "solid 5px red");
</script>这都能过
<script type="text/javascript">
$("div>label").css("border", "solid 5px red");
</script>这都能过
2015-08-04
$("*").attr("disabled", "true");
就一个*号这么简答
就一个*号这么简答
2015-08-04
$("button").attr("disabled","true");= $(#"btntest").attr("disabled","true");
2015-08-04
<script type="text/javascript">
$(function () {
$("#tabs").tabs({
//设置各选项卡在切换时的动画效果
fx: { opacity: "toggle", height: "toggle" },
event: "mousemove" //通过移动鼠标事件切换选项卡
})
});
</script>
$(function () {
$("#tabs").tabs({
//设置各选项卡在切换时的动画效果
fx: { opacity: "toggle", height: "toggle" },
event: "mousemove" //通过移动鼠标事件切换选项卡
})
});
</script>
2015-08-04