Home > Article > Web Front-end > Some special usage of javascript_javascript skills
, can be exchanged like:
Two functions can be exchanged, just like ordinary variables. <script> <BR> /*function update() <BR> { <BR> var name = dwr.util.getValue("demoName"); <BR> Demo.sayHello(name, function(data){ <BR> dwr.util.setValue("demoReply", data); <BR> dwr.util.setValue("demoReply2",data); <BR> }); <BR> }*/ <BR> /* <BR> function setData(data) <BR> { <BR> dwr.util.setValue("demoReply", data); <BR> dwr.util.setValue("demoReply2",data); <BR> } <BR> function update() <BR> { <BR> var name = dwr.util.getValue("demoName"); <BR> Demo.sayHello(name,setData); <BR> } <BR> */ <BR> function update() <BR> { <BR> var name = dwr.util.getValue("demoName"); <BR> var name2 = $("demoName").value; <BR> var name3 = document.getElementById("demoName").value; <BR> alert(name2+name3+name); <BR> Demo.sayHello(name,{ <BR> callback:function(data) <BR> { <BR> dwr.util.setValue("demoReply",data); <BR> dwr.util.setValue("demoReply2",data); <BR> } <BR> }); <BR> } <BR> hot = function hot(){ alert("Sweat.");} <BR> cold = function cold(){ alert("Shiver.");} <BR> function swap() <BR> { <BR> temp = hot; <BR> hot = cold; <BR> cold = temp; <BR> alert("Swap."); <BR> } <BR> </script>