jQuery中this与$(this)的区别

浅谈jQuery this和$(this)的区别及获取$(this)子元素对象的方法 1.JQuery this和$(this)的区别 相信很多刚接触JQuery的人,很多都会对$(this)和this的区别模糊不清,那么这两者有什么区别呢? 首先来看看JQuery中的  $()  这个符号,实际上这个符号在JQuery中相当于JQuery(),即$(this)=jquery();也就是说,这样可以返回一个jquery对象。那么,当你在网页中alert($(‘#id’));时,会弹出一个[object Object ],这个object对象,也就是jquery对象了。 那么,我们再回过头来说$(this),这个this是什么呢?假设我们有如下的代码: $("#deskto 立即下载

jQuery中this与$(this)的区别

  1. $("#textbox").hover(   
  2.       function() {   
  3.            this.title = "Test";   
  4.       },   
  5.       fucntion() {   
  6.           this.title = "OK”;   
  7.       }   
  8. ); 

这里的this其实是一个Html 元素(textbox),textbox有text属性,所以这样写是完全没有什么问题的。
但是如果将this换成$(this)就不是那回事了,Error--报了。this与$(this)的区别在此。

  1. Error Code:   
  2. $("#textbox").hover(   
  3.        function() {   
  4.           $(this).title = "Test";   
  5.        },   
  6.        function() {   
  7.           $(this).title = "OK";   
  8.        }   
  9. ); 

这里的$(this)是一个JQuery对象,而jQuery对象沒有title 属性,因此这样写是错误的。

JQuery拥有attr()方法可以get/set DOM对象的属性,所以正确的写法应该是这样:

正确的代码:

  1. $("#textbox").hover(   
  2.       function() {   
  3.          $(this).attr(’title’, ‘Test’);   
  4.       },   
  5.       function() {   
  6.          $(this).attr(’title’, ‘OK’);   
  7.       }   
  8. ); 

使用jQuery的好处是它包裝了各种浏览器版本对DOM对象的操作,因此统一使用$(this)而不再用this应该是比较不错的选择。

jQuery中this与$(this)的区别就介绍到这里。

从CentOS迁移到openEuler 24.03 LTS:手把手教你部署Java+MySQL+Redis+Nginx全栈环境 本文详细指导如何从CentOS迁移到openEuler 24.03 LTS,并部署Java+MySQL+Redis+Nginx全栈环境。涵盖系统配置、软件安装、性能优化及环境验证,助力企业级用户高效完成服务器迁移与部署。 阅读详情

相关推荐

期货套利策略(二)

接上一篇期货套利策略,随着对期货套利策略的深入了解,我发现套利策略不是那么好做的。下面将会讲碰到的一些问题。 上一篇文章中没有考虑滑点的问题,这里我们把滑点问题考虑进去。这里先说一些天勤api的买入点,天琴的买入点是当前K线的收盘价。碰到数据传输问题,还有计算等各方面问题,实际情况是无法在当前K线的收盘价买入的。这里我们把这方面问题考虑进去,利用api.wait_update()调到下一个k线数据...

qq_31611005的博客 1712

转jQuery中this与$(this)的区别

jQuery中this与$(this)的区别 $("#textbox").hover( function() { this.title = "Test"; }, fucntion() { this.title = "OK”; } ); 这里的this其实是一个Html ...

weixin_34248487的博客 270

最终篇——SWAT模型的建立

同理,Soil Data也是同样的方法导入,在Soil Database Options的选项中,选择UserSiol,用同样的方法导入土壤类型,进行重分类。打开窗口后,只定义HRU Thresholdes,其余两个不用设置,设定各数据单元的计算率,这里的10%的意思是计算精度,即分成级HRU计算单元太小,小于平均计算单元的10%,我们就不对这HRU单元进行计算(也就是说太破碎的计算单元不进行计算),若选择0%意味着全部进行计算,需要耗费大量的内存和时间,对计算机要求较高,不建议。

m0_72556434的博客 5621

$(this).attr $(this).val

jquery attr()方法 jquery中用attr()方法来获取和设置元素属性,attr是attribute(属性)的缩写,在jQuery DOM操作中会经常用到attr(),attr()有4个表达式。 1. attr(属性名)        //获取属性的值(取得第一个匹配元素的属性值。通过这个方法可以方便地从第一个匹配元素中获取一个属性的值。如果元素没有相应属性,则返回

menu_520的博客 6325

DETR系列文章之–Co-DETR

Co-DETR,并行训练多个辅助头,以一对多的标签分配方式进行监督从辅助头中提取正样本坐标,为解码器中的正样本的训练效率进行额外的定制化正样本query.一对一标签分配:每个GT框分配给一个特定的query(DETR),较少的正query导致低效训练,从编码器生成的潜在表示和解码器中的注意力学习分析这一问题。一对多标签分配:每个GT框分配给检测器输出的多个proposal/anchor,依赖NMS或者anchor生成(ATSS,RetinaNet,FCOS,PAA)。

weixin_43731232的博客 2110

计算机视觉:相机模型与参数标定

一、相机投影模型 1、小孔成像 2、相机模型中的四个平面坐标系 3、像主点偏移 4、畸变现象与内参矩阵 5、外参矩阵 二、相机标定:张正友棋盘格标定法 1、张正友棋盘格标定法描述 2、计算外参和内参 2.1 计算单应性矩阵H 2.2 计算内参数矩阵 2.3 计算外参数矩阵 3、实验:MATLAB实现 3.1 实验数据 3.2实验过程 3.3 实验结果 4、实验:OpenCV实现 4.1 实现代码 4.2 实验结果 5、实验分析与总结

DreamWendy的博客 2514

jquery_03基础

一、 1. 代码如下(示例): <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="js/jquery-3.6.0.min.js" type="text/javascript" charset="utf-8"></script> <scrip...

m0_58451019的博客 2259

FOC 电流采样方案对比(单电阻/双电阻/三电阻)

电流采样的作用 在FOC算法中,电流采样在反馈环节是相当重要的一部分,通常交流三相同步电机在进行坐标变换的时候,需要实时测量相电流,最终通过SVPWM实现电机转子磁场和定子磁场的同步转动,那么这里有三种方案,单电阻采样,双电阻采样,三电阻采样。本文参考ST的单电阻和三电阻采样以及TI的双电阻采样,结合实际中可能需要注意的地方进行总结分析。 单电阻采样 双电阻采样 三电阻采样 ...

一名热爱技术的工程师的博客。分享技术干货,记录美好生活。永远相信美好的事情即将发生。 4万+

jquery中的this

$()生成的是什么呢?实际上$()=jquery(),那么也就是说返回的是一个jquery的对象。 $(this)是jquery对象,能调用jquery的方法,例如click(), keyup()。 $(function () { $('button').click(function () { alert(this);//this 表示原生的DOM //$(

不忘初心,方得始终 1325

Agent Harness Engineering: AI Agent 执行管控与安全沙箱 原理与最佳实践

我们正站在计算范式转移的历史节点上。2024-2026 年间,AI 系统从被动的内容生成器(Generative AI)演变为主动的行动执行者(Agentic AI)。这一转变的根本特征是:根据 2026 年初的行业数据:然而,能力的提升伴随着风险的指数级增长。2024-2026 年间发生的多起标志性安全事件揭示了 Agent 系统的脆弱性:案例 1:Slack AI 数据外泄事件(2024 年 8 月)案例 2:制造业供应链攻击(2026 年 Q3)案例 3:Arup 深度诈骗案(2026 年 9 月)这

AI天才研究院 1669

Spring Boot入门(02):【教程】轻松搭建Spring Boot开发环境,启动你的第一个Web项目!

快速搭建开发环境和启动项目是每个开发人员必备的技能。本文将为您提供一些简单易懂的方法和技巧,以帮助您快速搭建开发环境和启动项目。我们将介绍如何选择适合您的开发工具、配置您的操作系统、安装必要的软件包和依赖项,并开始编写您的第一个应用程序。无论您是一位新手还是一位经验丰富的开发人员,本文都会给您提供有用的信息和实用的建议,让您在最短时间内快速搭建和启动开发项目。

**My Coding Family** 22万+

jquery的$(this)使用

一、this和$(this)区别  this通常是一个Html 元素,例如(textbox),textbox有text属性。可以在textbox的事件里面引用this获取元素 $(this)通常是一个JQuery对象 , 如: 我触发danji_jian()事件获取class为gouwuc_dan 的元素,则 寻找顺序将为this->gouwuc_shu(父节点)->gou

shuyuye的博客 1万+

【教程4>第2章>第18节】 GMSK调制系统的FPGA开发与matlab对比验证

GMSK(高斯最小频移键控)是一种连续相位的频移键控(CPFSK)调制方法,它在数字通信中得到了广泛应用,特别是在移动通信系统中。GMSK通过限制频率偏差的累积来减少带外辐射,并通过使用高斯滤波器对。

FPGA/MATLAB学习教程/源码/项目合作开发 998

jQuery中this与$(this)的区别总结

这里就谈谈this与$(this)的区别。 1、jQuery中this与$(this)的区别 $("#textbox").hover( function() { this.title = "Test"; }, fucntion() { this.title = "OK”; } ); 这里的this其实是一个html 元素(textbox),textbox有tex

qq_32864189的博客 363

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jquery里面的$(this)和this的区别

感谢原文作者:何少旭 原文链接:https://www.cnblogs.com/heshaoxu/p/7672736.html 前言 当你用的是jquery时,就用$(this),如果是JS,就用this。 示例 /*JQuery*/ $(this).html( $(this).html() + " BAM! "); /*JS*/ this.innerHTML(); this.reset(); 这个里的html()是JQUERY方法,用$(this).html(),当然,JS里也有相似方法inner.

Jason的学习笔记 697

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

jQuery中this与$(this)的区别总结 转

博客园 首页 新随笔 联系 管理 订阅 随笔- 15 文章- 0 评论- 2 jQuery中this与$(this)的区别总结 这里就谈谈this与$(this)的区别。 1、jQuery中this与$(this)的区别 $("#textbox").hover( function() { this.title = "...

maiyude的专栏 264

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

jquery中this与$(this)的用法区别

jquery中this与$(this)的用法区别.先看以下代码: $("#textbox").hover( function() { this.title = "Test";  }, fucntion() { this.title = "OK”;  } ); 这里的this其实是一个Html 元素(textbox),te...

weixin_30767835的博客 100

jQuery中this与$(this)的使用与区别

this与$(this)的区别 this其实是一个Html 元素,是一个javascript对象,常用其来为其属性赋值。 $(this)是一个jQuery对象,不存在html的属性,只能通过方法传参的方式为属性赋值。 如下代码 $(“#textbox”).hover( function() { this.title = “Test”; }, fucntion() { this.t...

进化的深山猿 3047

JQuery this和$(this)的区别及获取$(this)子元素对象的方法

1.JQuery this和$(this)的区别 // this其实是一个Html 元素。 // $this 只是个变量名,加$是为说明其是个jquery对象。 // 而$(this)是个转换,将this表示的dom对象转为jquery对象,这样就可以使用jquery提供的方法操作。 相信很多刚接触JQuery的人,很多都会对$(this)和th

Roninwz的博客 2万+

jQuery中的$(“this“)和$(this)的区别

$(this)取出当前对象并转换为jQuery对象 $(“this”)是使用标签选择器,查找名为this的标签 $(this)是jquery对象,能调用jquery的方法,例如click()等 this是html元素对象,能调用元素属性,例如this.id、this.value $(this) $(this)取出当前对象并转换为jQuery对象 $(this)是jquery对象,能调用jquery的方法,例如click()等 实例代码: <!DOCTYPE html> <html la.

weixin_46370867的博客 1385

JQuery this和$(this)的区别

this其实是一个Html 元素。 $this 只是个变量名,加$是为说明其是个jquery对象。 而$(this)是个转换,将this表示的dom对象转为jquery对象,这样就可以使用jquery提供的方法操作。 先来看看JQuery中的 $() 这个符号,实际上这个符号在JQuery中相当于JQuery(),即$(this)=jquery(); 也就是说,这样可以...

WHL1423的博客 139
上一篇: 10 个免费的 C/C++ 集成开发环境
下一篇: JS操作JSON总结
HackProgramer
博客等级 码龄12年 255粉丝 23原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值