JS and a href
Notice the semicolon ending in the href, closing the quotation marks.
< a href = "javascript:;" > empty link </ a > < href = "javascript: Alert (' a '); " </ a
650) this.width=650; "title=" image "style=" Background-image:none; "border=" 0 "alt=" image "src=" http://s3.51cto.com/ Wyfs02/m00/9a/40/wkiom1ltzuutrextaabw4m1zn8w500.png "" 346 "height=" 138 "/>
Generally, it may be the code, generally let it empty. Empty can also use the pound sign ' # ', but not very well.
ClassName
<style>#div1{width:100px;Height:100px;Border:1px solid Black;}. Box{background:Red;}</style><Script>functiontored () {varOdiv=document.getElementById ('Div1'); Odiv. className ='Box'; Do not write class}</Script></Head><Body><inputtype= "button"value= "Turn red"onclick= "tored ()" /><DivID= "Div1">
1. getElementById is connected to the ID. But there is no way to connect with class.
getElementById () |
Returns a reference to the first object that owns the specified ID. |
getelementsbyname () |
Returns a collection of objects with the specified name. |
getElementsByTagName () |
Returns a collection of objects with the specified label name. |
To use JS based/create classname index style. You need to add a level two attribute '. ClassName ' after getelement.
The label that was added after the specified ID is not only indexed from the ' pound ' index for the style of the ID, but also from the ' dot ' index for the class style.
2. getelement.classname = ' box '; The resulting change://The above example is the same as odiv for a different argument.
If the Class=xxx attribute is already in the <div> tag, then the event action leads to the function, CLASS=XXX will be modified to Class=box
If <div> does not have a class =xxx, it will be created incidentally when the script is executed.
Recall that if <div> does not specify a style = XXX, then Getelement.style.backgroud will also automatically create
GetElement. + Style/class/type/href/value and so on, want to change to add all can be very convenient and casual. I'm afraid you don't change.
This is just one way.
-There are getelement [' value '] in such a way that the brackets are quoted, and. The Out property of the (dot) is the same. It is generally not a special case to use ['] this way.
If ['] is to refer to a variable that assumes a = ' width ', then [' a '] becomes [' width '] so that it does not conform to the concept of getelement [' property '].
This time the processing method can be [a] without the quotation marks!
-All of them. can be replaced with [']
= box ; //The following is an equivalent
odiv[' className '] = ' Box ' ;
Multilayer can also, odiv[' style ' [' width '] = ' 40px '
-When do I need to use [']? Function parameters can generally be passed to the value, sometimes to the property name on behalf of the property, it is necessary to use the ["]
650) this.width=650; "title=" image "style=" margin:0px; Background-image:none; "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/9A/41/wKiom1lTZU7BYhqjAAD9_ Iaqx4a855.png "" 244 "height=" 232 "/>
JS Embedded HTML Run order:
-Performs an event action, executes a pointer to the JS function, and modifies the specified ID tag.
JS embedded HTML code to write the order:
-Want to change what effect, label Id/class to specify effect label, use. or # create {style}, call ID to write the logic to change CSS, trigger with event function.
JS and a href className js write order with Run order string or variable embed brackets instead of dot number