PHP and JQuery Stuff

Declaring non Existing object:
In order to comply with E_STRICT standards prior to PHP 5.4, or the normal E_WARNING error level in PHP >= 5.4, assuming you are trying to create a generic object and assign the property success, you need to declare $res as an object of stdClass in the global namespace:
$res = new \stdClass();
$res->success = false;
Jquery Email Regex:
var userinput = $(this).val();
var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i

if(!pattern.test(userinput))
{
  alert('not a valid e-mail address');
}​

Jquery Session:

https://www.w3schools.com/jsref/prop_win_localstorage.asp

How to bind click event to dynamically created HTML elements in jQuery

If you try to do something with the elements that are dynamically added to DOM using the jQuery click() method it will not work, because it bind the click event only to the elements that exist at the time of binding. To bind the click event to all existing and future elements, use the jQuery on() method. Let's take a look at an example to understand how it basically works:
  • <script>
  •     $(document).ready(function(){
  •         $("button").click(function(){
  •             $("ol").append("<li>list item <a href='javascript:void(0);' class='remove'>&times;</a></li>"); 
  •         });
  •         $(document).on("click", "a .remove" , function() {
  •             $(this).parent().remove();
  •         });
  •     });
  • </script>

Comments

Popular posts from this blog

Generate SHA-1 and SHA-256 for Debug and Release android app

Transfer file to Server and vice versa

How to Import and Export MySQL Database Command line in Linux