Skip to content
Browse files

img

  • Loading branch information...
1 parent 4bed031 commit 784067cd98d59ece1e46e45f0403999683742c19 Fan Yu committed
Showing with 43 additions and 11 deletions.
  1. BIN JqueryTest.suo
  2. +43 −11 JqueryTest/default.htm
View
BIN JqueryTest.suo
Binary file not shown.
View
54 JqueryTest/default.htm
@@ -5,22 +5,54 @@
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
</head>
<body>
- <p>Hellow world!</p>
- <div id="test"></div>
+ <p>
+ Hellow world!</p>
+ <div id="test">
+ </div>
<input id="run" type="button" value="button" />
- <img alt="" src="fry.jpg" />
- <div>move</div>
+ <img alt="" src="fry.jpg" style="border: 2px solid red;" />
+ <div>
+ move</div>
<script type="text/javascript">
// $("p").empty()
//$("#test").html("hahah")
-// $("#run").click(
-// function () {
-// $("div:not(:animated)").animate({left:"+=20"},1000);
-// }
-// );
-// window.onload = function () { alert("loaded"); }
+ // $("#run").click(
+ // function () {
+ // $("div:not(:animated)").animate({left:"+=20"},1000);
+ // }
+ // );
+ // window.onload = function () { alert("loaded"); }
// $(document).ready(function () { alert("ready"); });
- $("img").css("border", "5px solid orange");
+ // $("img").css("border", "5px solid orange");
+ var imges = new Array();
+ imges.contains = function (arr) {
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] == arr)
+ return true;
+ }
+ return false;
+ }
+
+ function addborder(event) {
+ $(this).css("border", "5px solid orange");
+ }
+ function removeborder(event) {
+ if (!imges.contains(this)) {
+ $(this).css("border", "");
+ }
+ }
+ $("img").hover(addborder, removeborder);
+
+ $("img").bind("click", function (event) {
+ if (!imges.contains(this)) {
+ imges.push(this);
+ $(this).css("border", "5px solid orange");
+ }
+ else {
+ imges.splice($.inArray(this, imges), 1);
+ $(this).css("border", "");
+ }
+ });
</script>
</body>
</html>

0 comments on commit 784067c

Please sign in to comment.
Something went wrong with that request. Please try again.