JavaScript Set Cursor Style

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script language="JavaScript">

    function setCursorByID(id, cursorStyle) {
        var elem;
        if (document.getElementById && (elem = document.getElementById(id))) {
            if (elem.style)
                elem.style.cursor = cursorStyle;
        }
    }

</script>
</head>
<body>
    <span style="cursor: auto;">auto</span>
    <span style="cursor: move;">move</span>
    <span style="cursor: no-drop;">no-drop</span>
    <span style="cursor: col-resize;">col-resize</span>
    <span style="cursor: all-scroll;">all-scroll</span>
    <span style="cursor: pointer;">pointer</span>
    <span style="cursor: not-allowed;">not-allowed</span>
    <span style="cursor: row-resize;">row-resize</span>
    <span style="cursor: crosshair;">crosshair</span>
    <span style="cursor: progress;">progress</span>
    <span style="cursor: e-resize;">e-resize</span>
    <span style="cursor: ne-resize;">ne-resize</span>
    <span style="cursor: default;">default</span>
    <span style="cursor: text;">text</span>
    <span style="cursor: n-resize;">n-resize</span>
    <span style="cursor: nw-resize;">nw-resize</span>
    <span style="cursor: help;">help</span>
    <span style="cursor: vertical-text;">vertical-text</span>
    <span style="cursor: s-resize;">s-resize</span>
    <span style="cursor: se-resize;">se-resize</span>
    <span style="cursor: inherit;">inherit</span>
    <span style="cursor: wait;">wait</span>
    <span style="cursor: w-resize;">w-resize</span>
    <span style="cursor: sw-resize;">sw-resize</span>
    <div>
        <a id="e1h" href="#" style="cursor: help;" onclick="setCursorByID('e1','help');return false;">help</a> 
        <a id="e1w" href="#" style="cursor: wait;" onclick="setCursorByID('e1','wait');return false;">wait</a>
        <a id="e1m" href="#" style="cursor: move;" onclick="setCursorByID('e1','move');return false;">move</a> 
        <a id="e1c" href="#" style="cursor: crosshair;" onclick="setCursorByID('e1','crosshair');return false;">crosshair</a>
        <a id="e1t" href="#" style="cursor: text;" onclick="setCursorByID('e1','text');return false;">text</a> 
        <a id="e1a" href="#" style="cursor: default;" onclick="setCursorByID('e1','default');return false;">default</a> 
        <a id="e1a" href="#" style="cursor: pointer;" onclick="setCursorByID('e1','pointer');return false;">pointer</a> 
        <a id="e1a" href="#" style="cursor: auto;" onclick="setCursorByID('e1','auto');return false;">auto</a>
    </div>
    <div>
        <a id="e1" href="#" onclick="setCursorByID('e1','help');return false;">test</a> 
    </div>
</body>
</html>

原文:http://www.javascripter.net/faq/stylesc.htm

转载于:https://www.cnblogs.com/yydaddy/p/4195853.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
-5):"; int choice; cin >> choice; switch (choice) { case 0: exitFlag可以使用JavaScript来增强留言板的验证功能,确保用户输入的数据符合要求。以下是一个简单的JavaScript验证留言板的示例: ```html <!DOCTYPE html> <html> <head> <title>留言板</title = true; cout << "程序已退出!" << endl; break; case 1: cout << "请输入> <style> .container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f2f2f2; border: 1px solid #ccc; box-shadow: 0学生信息(姓名 年龄 性别 学号 成绩):" << endl; string name, gender, id; int 0 10px #ccc; } form { display: flex; flex-direction: column; align-items: age; float score; cin >> name >> age >> gender >> id >> score; studentManager.addStudent(Student(name, age center; } input[type="text"], textarea { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box, gender, id, score)); cout << "学生信息已添加!" << endl; break; case 2: ; } input[type="submit"] { background-color: #007bff; color: #fff; border: none cout << "请输入要删除的学生学号:"; cin >> id; studentManager.deleteStudent(id); cout; padding: 10px 20px; border-radius: 5px; cursor: pointer; } .message { margin-bottom: 20px; padding: 10px; background-color: #fff; border: 1 << "学生信息已删除!" << endl; break; case 3: cout << "请输入要修改的px solid #ccc; border-radius: 5px; box-shadow: 0 0 10px #ccc; word-break: break-all; } .message p:first-child { font-weight: bold; margin-bottom: 5px; 学生学号和新的学生信息(姓名 年龄 性别 学号 成绩):" << endl; string newName, } .message p:last-child { font-style: italic; font-size: 12px; color: #999 newGender, newId; int newAge; float newScore; cin >> id >> newName >> newAge >> newGender; } .error { color: red; font-size: 12px; margin-top: 5px; } </style> </head> <body> <div class="container"> <h1>留言板</h1 >> newId >> newScore; studentManager.updateStudent(id, Student(newName, newAge, newGender, newId, newScore> <form action="#" method="post" onsubmit="return validateForm()"> <label for="name">姓名:</label> <input type="text" id="name" name="name" required> <label for="email">邮箱:</label> )); cout << "学生信息已修改!" << endl; break; case 4: cout << "请输入<input type="text" id="email" name="email" required> <label for="message">留言:</label> <textarea id="message" name="message" rows="5" required></textarea> <input type="submit" value="提交留言要查找的学生学号:"; cin >> id; studentManager.findStudent(id); break; case "> </form> <div id="messages"> <!-- 这里是留言展示区 --> </div5: studentManager.displayAll(); break; default: cout << "输入有误,请重新输入!" << endl> </div> <script> function validateForm() { var name = document.getElementById("name").value; var email = document.getElementById("email").value; var message = document.getElementById("message").value; var error = document.getElementById("error"); ; break; } } return 0; } ``` 该学生管理系统共有两个类:`Student if (name == "") { error.innerHTML = "请输入您的姓名"; return false; } if (email == "")` 和 `StudentManager`,其中 `Student` 类用于表示学生信息,`StudentManager` 类用于管理学生 { error.innerHTML = "请输入您的邮箱"; return false; } if (message == "") { error.innerHTML = "请输入留言内容"; return false; } return true; } </script> </body> </html信息。在 `Student` 类中,定义了私有属性 `name`、`age`、`gender`、`id`> ``` 在这个示例中,我们添加了一个JavaScript函数`validateForm()`来验证表单数据。该函数首 和 `score`,分别表示学生姓名、年龄、性别、学号和成绩。同时,定义了公先获取表单中的姓名、邮箱和留言内容,然后检查这些值是否符合要求。 如果任何一个值为空,函数会在页面上显示一个错误信息。否则,函数会返回`true`,表单将被有方法 `setInfo`、`getName`、`getAge`、`getGender`、`getId`、`getScore`提交。 在表单元素中,我们添加了一个`onsubmit`属性,用于调用`validateForm()`函数。 和 `display`,分别用于设置、获取和显示学生信息。在 `StudentManager` 类中,定义了私这样,在用户单击提交按钮时,表单数据将被先提交给JavaScript函数进行验证,只有在验证通过后才会将表单数据提交给服务器。 在代码中,我们还添加了一个`<div>`元素来展示错误信息有属性 `students`,用于存储所有学生信息。同时,定义了公有方法 `addStudent`、`delete。如果用户未输入必填字段,错误信息将显示在该元素中。 通过这些步骤,您可以使用JavaScript来增强留言板的验证功能,确保用户输入的数据符合要求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值