搜索
首页web前端前端问答jquery怎么用CSS()设置鼠标禁止样式

方法:只需用CSS()将鼠标样式属性“cursor”的值设置为“not-allowed”即可,语法为“元素对象.css("cursor","not-allowed")”或“元素.css({"cursor":"not-allowed"})”。

jquery怎么用CSS()设置鼠标禁止样式

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。

想要设置鼠标禁止样式,只需用的cursor属性。

只需用CSS()将鼠标样式属性“cursor”的值设置为“not-allowed”即可。

设置语法有两种:

元素对象.css("cursor","not-allowed")
元素对象.css({"cursor":"not-allowed"})

实现示例:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<script src="js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				$("button").click(function() {
					// $("p").css("cursor","not-allowed");
					$("p").css({"cursor":"not-allowed"});
				});
			});
		</script>
	</head>

	<body>
		<p>一个p元素,让鼠标移动到该元素上</p>
		<button>设置鼠标禁止样式</button>
	</body>

</html>

1.gif

说明:

cursor属性定义了鼠标指针放在一个元素边界范围内时所用的光标形状。

当cursor属性的属性值为“not-allowed”,则鼠标光标形状为禁止图案。

cursor属性取值如下,默认值为default

crosshair;

十字准心

光标表现为十字准线

cursor: pointer;                     
cursor: hand;                    
写两个是为了照顾IE5,它只认hand。

光标标以暗示(手指)的形式来表明有一个连接

cursor: wait;

等待/沙漏

光标暗示当前程序正忙(一般为一块表或是一个沙漏)

cursor: help;

帮助

光标暗示当前位置可得到帮助(一般为问号或是气球)

cursor: no-drop;

无法释放

cursor: no-drop;

cursor: text;

文字/编辑

光标暗示当前所处位置为文字内容

cursor: move;

可移动对象

光标暗示一些东西应该被移动

cursor: n-resize;

向上改变大小(North)

边缘可向上移动(北)

cursor: s-resize;

向下改变大小(South)

边缘可向下方移动(南)

cursor: e-resize;

向右改变大小(East)

box边缘可向右(东)边移动

cursor: w-resize;

向左改变大小(West)

边缘可向左移动(西)

cursor: ne-resize;

向上右改变大小(North East)

光标暗示box的边缘可向右上方移动(东北方向)

cursor: nw-resize;

向上左改变大小(North West)

边缘可向左上方移动(西北)

cursor: se-resize;

向下右改变大小(South East)

边缘可向右下方移动(东南)

cursor: sw-resize;

向下左改变大小(South West)

边缘可向左下方移动(西南)

cursor: auto;

自动

浏览器设置一个光标

cursor:not-allowed;

禁止

cursor:not-allowed;

cursor: progress;

处理中

cursor: progress;

cursor: default;

系统默认

默认的光标状态(通常为一个箭头)

cursor: url(' # ');                    
# = 光标文件地址      (注意文件格式必须为:.cur 或 .ani)。

用户自定义(可用动画)

自定义光标的url位置           

注意:在定义完自定义的光标之后在末尾加上一般性的光标,以防那些url所定义的光标不能使用

大家可能会说,cursor属性值这么多,怎么记呀?其实大家不用担心,在实际开发中,我们一般只用到“default”和“pointer”这两个属性值,其他的一般都很少用得上。如果实在没办法还需要其他的,那就回来查这种表就行了。

【推荐学习:jQuery视频教程web前端开发

以上是jquery怎么用CSS()设置鼠标禁止样式的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
反应的局限性是什么?反应的局限性是什么?May 02, 2025 am 12:26 AM

Include:1)AsteeplearningCurvedUetoItsVasteCosystem,2)SeochallengesWithClient-SiderEndering,3)潜在的PersperformanceissuesInsuesInlArgeApplications,4)ComplexStateStateManagementAsappsgrow和5)TheneedtokeEedtokeEedtokeEppwithitsrapideDrapidevoltolution.thereedtokeEppectortorservolution.thereedthersrapidevolution.ththesefactorsshesssheou

React的学习曲线:新开发人员的挑战React的学习曲线:新开发人员的挑战May 02, 2025 am 12:24 AM

reactischallengingforbeginnersduetoitssteplearningcurveandparadigmshifttocoment oparchitecent.1)startwithofficialdocumentationforasolidFoundation.2)了解jsxandhowtoembedjavascriptwithinit.3)

为React中的动态列表生成稳定且独特的键为React中的动态列表生成稳定且独特的键May 02, 2025 am 12:22 AM

ThecorechallengeingeneratingstableanduniquekeysfordynamiclistsinReactisensuringconsistentidentifiersacrossre-rendersforefficientDOMupdates.1)Usenaturalkeyswhenpossible,astheyarereliableifuniqueandstable.2)Generatesynthetickeysbasedonmultipleattribute

JavaScript疲劳:与React及其工具保持最新JavaScript疲劳:与React及其工具保持最新May 02, 2025 am 12:19 AM

javascriptfatigueinrectismanagbaiblewithstrategiesLike just just in-timelearninganning and CuratedInformationsources.1)学习whatyouneedwhenyouneedit

使用USESTATE()挂钩的测试组件使用USESTATE()挂钩的测试组件May 02, 2025 am 12:13 AM

totlecteactComponents通过theusestatehook,使用jestandReaCtteTingLibraryToSigulation Interactions andverifyStatAtaTeChangesInTheUI.1)renderthecomponentAndComponentAndComponentAndCheckInitialState.2)模拟useclicklicksorformsormissionsions.3)

React中的钥匙:深入研究性能优化技术React中的钥匙:深入研究性能优化技术May 01, 2025 am 12:25 AM

KeysinreactarecrucialforopTimizingPerformanceByingIneFefitedListupDates.1)useKeyStoIndentifyAndTrackListelements.2)避免使用ArrayIndi​​cesasKeystopreventperformansissues.3)ChooSestableIdentifierslikeIdentifierSlikeItem.idtomaintainAinainCommaintOnconMaintOmentStateAteanDimpperperFermerfermperfermerformperfermerformfermerformfermerformfermerment.ChosestopReventPerformissues.3)

反应中的键是什么?反应中的键是什么?May 01, 2025 am 12:25 AM

ReactKeySareUniqueIdentifiers usedwhenrenderingListstoimprovereConciliation效率。1)heelPreactrackChangesInListItems,2)使用StableanDuniqueIdentifiersLikeItifiersLikeItemidSisRecumended,3)避免使用ArrayIndi​​cesaskeyindicesaskeystopreventopReventOpReventSissUseSuseSuseWithReRefers和4)

反应中独特键的重要性:避免常见的陷阱反应中独特键的重要性:避免常见的陷阱May 01, 2025 am 12:19 AM

独特的keysarecrucialinreactforoptimizingRendering和MaintainingComponentStateTegrity.1)useanaturalAlaluniqueIdentifierFromyourDataiFabable.2)ifnonaturalalientedifierexistsistsists,generateauniqueKeyniqueKeyKeyLiquekeyperaliqeyAliqueLiqueAlighatiSaliqueLiberaryLlikikeuuId.3)deversearrayIndi​​ceSaskeyseSecialIndiceSeasseAsialIndiceAseAsialIndiceAsiall

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器