jQuery元素属性操作示例(设置、获取和删除元素属性)
本文说明了jQuery元素属性操作的方法。分享给大家参考,如下:
html healtheta http-equiv=' Content-Type ' Content=' text/html;charset=utf-8 '/title/title script src=' http : js/jquery-1 . 10 . 1 . min . js ' type=' text/JavaScript '/script script type=' text/JavaScript '/![CDATA[$(function(){ //设置属性‘title’$(‘input 3360 eq(0)’)。单击(function () {$ ('p '))。attr ('title ','选择你最喜欢的水果');});//获取属性“title”$(“input 3360 eq(1)”)。click (function () {alert ($ ('p '))。p元素的attr(' title ');});//删除属性“title”$(“input 3360 eq(2)”)。单击(function () {$ ('p '))。remove attr(' title ');});});//]]/script/headsdyinputtype=' button '值='设置p元素的属性' title '/inputtype=' button '值='获取p元素的属性' title '/inputtype=' button '值='删除p元素的属性' title '/p title ' '/p title=' T/pul Li title=' apple ' apple/Li Li title=' orange ' orange/Li title='菠萝'菠萝/li/ul/body/html渲染:
更多对jQuery感兴趣的读者,请查看本网站主题:《jQuery常见事件用法与技巧总结》、《jQuery常用插件及用法总结》、《jQuery操作json数据技巧汇总》、《jQuery扩展技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery表格(table)操作技巧汇总》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》、《jquery选择器用法总结》。
希望本文对大家的jQuery程序设计有所帮助。
版权声明:jQuery元素属性操作示例(设置、获取和删除元素属性)是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。