jquery in action2的学习笔记(二)
二:Bringing pages to life
with jQuery
<img id="myImage" src="image.gif" alt="jquery in action2的学习札记(二)" data-custom ="some value"/>
1:As an example of using the each() method, we could use the following code to set the
id property of every element in the DOM to a name composed of the element’s tag
name and position within the DOM:
Recall that the attr() method will return undefined if the attribute in question
doesn’t exist, so this statement will throw an error if the <p> element doesn’t possess
any class names.
We could solve this by first checking for the attribute
8:expand the width of all elements
in the wrapped set by 20 pixels as follows:$('input,select').val(['one','two','three']);