1.0 Encoding Encode,decode
function HtmlEncode (value) {return $ (' <div> '). Text (value). html (); }function HtmlDecode (value) {return $ (' <div> '). HTML (value). text (); }
2.0 Pre-operation confirmation
<onclick= "return confirm (' OK to delete? ');" href= "/delete/id"> Delete </a>
3.0 Get URL Parameters
function getquerystring (name) { varnew RegExp ("(^|&)" + name + "= ([^&]*) (&|$)", "I" ); var r = window.location.search.substr (1). Match (reg); if NULL return return NULL
4.0 Binding key Events
// #strKeyInput text box ID keypress event name without changing //Searchbykey () triggered event function ( Event) { if (Event.keycode = = ") Searchbykey ();});
5.0 front end prevents duplicate commits
$ ("#btnSubmit"). attr (' disabled ', true);
Further validation is required on the server side to prevent duplicate data submissions.
6.0 Refresh the current page
Location.replace (LOCATION.HREF);
7.0 Back to Previous page
Window.history.back ();
I want to add ...
Common methods of JS and jquery