(Source: wuchao.cnblogs.com)
Write a simple jquery-based dialog box
Css:
{ :; :; :; :; :; } { :; :; :; :; :; } { :; :; } { :; :; :; } { :; :; } { :; :; } { :; :; :; :; :; :; }
Js:
Confirms: defaults = title: "Delete Confirmation" message: "You are about to delete this item. <br/> It cannot be restored at a later time! Continue? "" Yes ": {'class': 'blue', 'Action': () {alert (" You clicked Yes "" No ": {'class ': 'Gray ', 'Action ':() {$ ("# dialog" opts = $ ("<div id = 'Dialog '> <div class = 'title'> <span id = 'tcontent'>" + defaults. title + "</span> </div> <div class = 'content'> <span id = CContent>" + defaults. message + "</span> </div> <div class = 'buttons'> <input id = 'ttbutton1' style = 'background-color:" + defaults. buttons ['yes'] ['class'] + "'Type = 'Button 'value = 'yes'/> <input id = 'ttbutton2' type = 'button 'style = 'background-color: "+ defaults. buttons ['no'] ['class'] + "'value = 'no'/> </div> "). appendTo ("body" $ ("# TTButton1 "). bind ("click", defaults. buttons ['yes'] ['action' $ ("# TTButton2 "). bind ("click", defaults. buttons ['no'] ['action' $ ("# dialog" ).css ("top", ($ (document ). height ()-$ ("# dialog "). height ()/2-100 $ ("# dialog" ).css ("left ", ($ (Document). width ()-$ ("# dialog"). width ()/2 title: "test" message: "This is a test dialog box! "" Yes ": {'class': 'red', 'Action': () {alert (" You say to cx: True 2! "" No ": {'class': 'Gray ', 'Action': () {$ (" # dialog "}
Html test code:
Simple and complete
Problem: $("123 "). appendTo ("p"); invalid $ ("<B> 123 </B> "). appendTo ("p ");