标签:
$()
css()
省略原生的循环操作
$ == jQuery
click()
html()
可以共存,不能混写
函数中this是原生的,$(this)转换为jQ对象
<!DOCTYPE html> <html> <head> <title></title> <style> div{ width: 100px; height: 100px; float: left; border: 1px solid #333; } </style> </head> <body> <span>red</span> <span>blue</span> <span>green</span> <span>yellow</span> <br> <div></div> <div></div> <div></div> <div></div> <script src="jquery-1.11.1.js"></script> <script> var color = ‘‘; $(‘span‘).click(function(){ color = $(this).html(); }); $(‘div‘).click(function(){ $(this).css(‘backgroundColor‘,color); }); </script> </body> </html>
标签:
原文地址:http://www.cnblogs.com/jiujiaoyangkang/p/5506963.html