2013年8月3日 星期六

html javascript simple help message line

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>index(element)¤èªk</title>
<style type="text/css">
<!--
body{
    font-size:12px;
    font-family:Arial, Helvetica, sans-serif;
}
div{
    border:1px solid #003a75;
    background:#fcff9f;
    margin:5px; padding:5px;
    text-align:center;
    height:20px; width:20px;
    float:left;
    cursor:help;
}
-->
</style>
<script language="javascript" src="jquery.min.js"></script>
<script language="javascript">
$(function(){
    //click()·s¼WÂIÀ»¨Æ¥ó
    $("div").click(function(){
        //±N¶ô¥»¨­¥ÎthisÃöÁä¦r¶Ç¤J¡A±q¦ÓÀò¨ú¦Û¨­ªº§Ç¸¹
        var index = $("div").index(this);
        $("span").html(index.toString());
    });
});
</script>
</head>
<body>
<div>0</div><div>1</div><div>2</div><div>3</div><div>4</div><div>5</div>
ÂIÀ»ªºdiv¶ô§Ç¸¹¬°¡G<span></span>
</body>
</html>

沒有留言:

張貼留言