I have a need to remove multiple lines except the first line in a string. For example, “line1\n\line2\nline3″ should be converted to “line1″. At the beginning, I used the following […]

We usually use the following function to bind an event handler to a jQuery object on some event: $( “button” ).on(“click”, function(event){}); The .on method actually has another form: $( […]

We’ve talked about simulating mouse click in C language. Today, we’ll learn how to simulate mouse click in jQuery. There seem quite a few methods to simulate a mouse click […]

I’ve been looking for the javascript sleep function for a long time. Unfortunately, although most programming languages such as C/C++, php, python, etc. have a sleep function, javascript¬† has neither […]

I often got confused about JSON and JSON string. JSON is the code you write in your javascript script to represent an object, so the code is called JavaScript Object […]

I love php array because the array’s key can not only be number but also be string. $arr=array(“a”,”b”,”c”); $arr=[“a”,”b”,”c”]; $arr=array(“k1″=>”a”,”k2″=>”b”,”k3″=>”c”); $arr=[“k1″=>”a”,”k2″=>”b”,”k3″=>”c”];   That makes it an association array or a […]

The Date object looks simple. It has methods to get the date, month, year, hour,minute, second that it represents.¬† And it has methods to set these values. But it has […]