In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces whether jquery can add attributes to the picture of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe you can read this jquery whether you can add attributes to the picture article will have a harvest, let's take a look.
Jquery can add attributes to pictures. Two ways to add attributes: 1, use attr () to add attributes to img elements, syntax "$(" img "). Attr (" attribute name "," value ")"; 2, use prop () to add attributes to the picture element, syntax "$(" img ") .attribute (" attribute name "," value ")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
There are two ways to set properties in jquery
Attr ()
Prop ()
1. Use attr ()
The attr () method sets or returns the properties and values of the selected element.
When this method is used to set property values, one or more attribute / value pairs are set for matching elements.
$("img") .attr ("attribute name", "attribute value")
Example:
$(document) .ready (function () {$("button") .click (function () {$("img"). Attr ("align", "right");})
Add an align attribute to the picture to set the right alignment
2. Use prop ()
The prop () method, like attr (), sets or returns the properties and values of the selected element.
When this method is used to set attribute values, one or more attribute / value pairs are set for a collection of matching elements.
Syntax:
$("img") .prop ("attribute name", "attribute value")
Example:
$(document) .ready (function () {$("button") .click (function () {$("img"). Prop ("alt", "alternative text of the image");})
Add an alt attribute to the picture
Extended knowledge: picture element img
The tag defines the image in the HTML page.
Tags have two required attributes: src and alt.
Attributes of the tag:
Attribute value description aligntop
Bottom
Middle
Left
RightHTML5 does not support it. HTML 4.01 is obsolete. Specifies how images are arranged according to the surrounding text. Loadingeager: load now
Lazy: delayed loading specifies whether the browser should load the image immediately or delayed. Alttext specifies the alternate text for the image. BorderpixelsHTML5 does not support it. HTML 4.01 is obsolete. Specifies the border around the image. Crossoriginanonymous
Use-credentials sets the cross-domain property of the image heightpixels specifies the height of the image. HspacepixelsHTML5 does not support it. HTML 4.01 is obsolete. Specifies the white space on the left and right side of the image. Ismapismap defines the image as a server-side image mapping. LongdescURLHTML5 does not support it. HTML 4.01 is obsolete. Point to the URL that contains a long image description document. SrcURL specifies the URL that displays the image. Usemap#mapname defines an image as a client-side image mapping. VspacepixelsHTML5 does not support it. HTML 4.01 is obsolete. Specifies the white space at the top and bottom of the image. Widthpixels specifies the width of the image. This is the end of the article on "whether jquery can add attributes to pictures". Thank you for reading! I believe you all have a certain understanding of the knowledge of "whether jquery can add attributes to pictures". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 206
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.