提交表单、初识jQuery 2022-2-23

news/2024/7/11 0:01:43 标签: jquery, javascript, 前端

一、提交表单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>提交表单</title>
    <!--MD5工具类-->
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
</head>
<body>
<form action="#" method="post">
    <p>
        <span>用户名:</span><input type="text" id="username" name="uname">
    </p>
    <p>
        <span>密码:</span><input type="password" id="password" name="pwd">
    </p>
    <!--绑定事件 onclick被点击-->
    <button type="submit" onclick="aaa()">提交</button>
</form>

<script>
    function aaa(){
        var uname = document.getElementById('username');
        var pwd = document.getElementById('password');
        console.log(uname.value);
        console.log(pwd.value);
        //MD5算法
        pwd.value = md5(pwd.value);
        console.log(pwd.value);

    }
</script>
</body>
</html>

在这里插入图片描述

在这里插入图片描述

初识jQuery

jQuery:公式:$(selector).action()

JavaScript
jQuery库,里面存在大量的JavaScript函数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>初识jQuery</title>
    <!--jQuery官网:https://jquery.cuishifeng.cn/-->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>

//选择器就是css的选择器

<!--公式:$(selector).action()-->
<a href="" id="test-jquery">点我</a>

<script>
    $('#test-jquery').click(function (){
        alert('Hello.jQuery')
    })
</script>
</body>
</html>

在这里插入图片描述

2.1选择器

<script>
    //jQuery  css中的选择器它全部都能用
    $('p').click();//标签选择器
    $('#id1').click();//id选择器
    $('.class1').click();//class选择器

</script>

文档工具站:https://jquery.cuishifeng.cn/

2.2事件

鼠标事件、键盘事件、其他事件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <style>
        #divMove{
            width: 500px;
            height: 500px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<!--要求:获取鼠标当前的一个坐标-->
mouse:   <span id="mouseMove"></span>
<div id="divMove">
在这里移动鼠标
</div>

<script>
    //当网页元素加载完毕之后,响应事件
    $(function (){
        $('#divMove').mousemove(function (e){
            $('#mouseMove').text('x:'+e.pageX + 'y:'+e.pageY)
        })
    });
</script>


</body>
</html>

在这里插入图片描述


http://www.niftyadmin.cn/n/864967.html

相关文章

说说 Linux 中的 sftp 上传、下载功能

在 centos7 中&#xff0c; /etc/ssh/sshd_config 中会配置 sftp-server 服务&#xff0c;也就是说 centos7 本身自带 sftp 功能&#xff1a; 在 secure CRT 中&#xff0c;右击已连接的 ssh 标签页&#xff0c;选择 Connect SFTP Session&#xff1a; 就会进入 sftp 窗口。 s…

Resource-Sharing(更新中)

更新时间&#xff1a;2018/07/30 前言 从开始接触数据挖掘、机器学习、深度学习&#xff0c;到现在积累了不少资料&#xff0c;一点点整理分享出来&#xff0c;书和论文会放在百度云盘里&#xff0c;有需要的自己下载哈&#xff01;这段时间比较忙&#xff0c;更新频率不会特…

说说如何使用 Python 遍历目录树

假设有这样一个任务&#xff0c;希望对某个文件夹&#xff08;包括所有子文件夹与文件&#xff09;中的所有文件进行处理。这就需要遍历整理目录树&#xff0c; 处理遇到的每个文件。 import os 遍历目录树 for folder_name,sub_folders,filenames in os.walk(F:\\dicts):prin…

【ML算法】监督学习——逻辑回归

更新时间&#xff1a;2019-05-21 概述 逻辑回归&#xff08;Logistic Regression&#xff0c;LR&#xff09;&#xff0c;西瓜书中叫做对数几率回归&#xff0c;虽然叫回归&#xff0c;但实际上是一种分类算法&#xff0c;主要处理二分类问题&#xff0c;LR模型简单&#xff…

操作DOM 2022-3-6

一、操作DOM <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>操作DOM</title><script src"http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> </head>…

Paper-Reading

更新时间&#xff1a;2022-01-18 Computer Vision 序号论文详解链接01VGG——Very Deep Convolutional Network For Large-Scale Image Recognition链接02Dynamic Routing Between Capsules链接03Convolutional Clustering for Unsupervised Learning链接04Tutorial on Varia…

【Python】常用模块(三)——collections模块中的几个常用方法详解

前言 本篇博客主要就少Python常用模块collections中的几个常用方法&#xff0c;作为一种更高级的数据结构&#xff0c;这个模块提供了几个高效的方法来处理数据。 Counter Counter用于统计元素个数&#xff0c;具体用法如下&#xff1a; >>> from clooections imp…

vue学习入门 2022-3-11

一、了解vue 是一套用于用户界面的渐进式框架&#xff0c;vue只关心视图层 Vue综合了Angular&#xff08;模块化&#xff09;和React&#xff08;虚拟DOM&#xff09;&#xff0c;而要实现通信功能的是用Axios 1.1在IDEA添加vue 初步了解vue <!DOCTYPE html> <htm…