Category : Javascript have tutorials for Javascript, here you can study articles of Javascript, Javascript posts collection, most popular and useful tutorials of Javascript, here you can find list of all relevant posts and example about Javascript, we have lists of tutorials and examples about Javascript.very simple and quick example collection of Latest Javascript category.

How to check image loaded or not in JQuery?

Sometimes we need to detect upto image load successfully, for example you want to do print text instead of image before load image. so you can do that using jquery load and error method. you can see bellow example: <strong>Example:</strong> <pre class="prettyprint lanh-js"> <script type="text/javascript"> $('.image') .load(function(){ console.log("Now loaded correctly"); }) .error(function(){ console.log("Found Error in loading image"); }); </script> </pre>

By Hardik Savani | April 15, 2016 | | 11599 Viewer | Category : Javascript

AngularJS - How to Limit String Length using Filter?

Some case we have enough space to display content, for example you have articale blog and you want to display saveral articale on homepage with limited content like this way : <pre> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate.... </pre> You can do it easily if you are work on any framework or something, but if you want to do on angular then you need to cr.....

By Hardik Savani | April 14, 2016 | | 19227 Viewer | Category : Javascript

JQuery - how to get attribute value example

If you are new and you want to get attribute value then you can get easily. sometime maybe we also need to get custom attribute value, i mean data attribute value. In following example i give you three way to get custom attribute value in jquery. <strong class="example">Example:</strong> <pre class="prettyprint lang-html"> <html lang="en"> <head> <title>Get Custom Attribute Value</title> <script src=""></script> </head> <body> <a href="" data-id="1" myname="hd">Ex.....

By Hardik Savani | April 14, 2016 | | 7384 Viewer | Category : Javascript

How to Check if Element is Exists or not in jQuery?

Most of the time we require to check specific element is exists or not in javascript. but jquery provide length() method that can help to check element is exists or not. If you are new and want to do this then see bellow example: <strong class="example">Example:</strong> <pre class="prettyprint lang-js"> <script type="text/javascript"> $(document).ready(function(){ if ($('.image').length) { console.log('yes, Image class is exists.'); } else { console.log('sorry, Image class is not exists.'); } }); </script> </pre>

By Hardik Savani | April 13, 2016 | | 7818 Viewer | Category : Javascript

JQuery - Display loading image on ajax call example

Sometimes, we want to display loading image or animation or text when fire every ajax request. In not for only one ajax request, but if you want to load image on every ajax request then you can do that using bellow example. I use ajaxStart() and ajaxComplete() function for show image until All POST or GET Ajax request. this both function will execute one each $.ajax request. <strong class="example">Example:</strong> <pre class="prettyprint lang-js"> <script type="text/javascript"> $(document).ready(function() { $(document).ajaxStart(function(){ $('#process_img').cs.....

By Hardik Savani | April 12, 2016 | | 18648 Viewer | Category : Javascript

Jquery ajax request example

If you are very fresher in jquery and you don't know how to work post ajax request then bellow example can help you. i gave you the example of POST ajax request with json, you can also easily modify this example. you also fire GET ajax request using this example. bellow example is a pretty simple to undestand how to work $.ajax method. so let's see bellow example and try to undestand. <strong class="example">Example:</strong> <pre class="prettyprint lang-php"> <html lang="en"> <head> <title>JQuery Ajax Demo</title> <script src="

By Hardik Savani | April 10, 2016 | | 9882 Viewer | Category : Javascript

How to parse json in jquery ajax?

When you are working php or .net etc and you return data like json_encode($data) on ajax request. but in front side you get like a string at that time you have to parse json object and get them. so, let's see example and learn how to use: <strong class="example">Example</strong> <pre class="prettyprint lang-php"> var request = $.ajax({ type: 'POST', dataType: 'json', url: '', data: {token:obj['token'],postid: obj['postid']} }); request.done(function(msg) { msg = JSON.parse(msg); msg.forEach(function(items) { var e = "notify-"+items.userid; .....

By Hardik Savani | April 5, 2016 | | 13929 Viewer | Category : Javascript

How to create scroll to top of the page by jquery animate ?

However you want the scrolling process to have animated effect. you have to follow bellow example. in this post you can add button for scrolling top with animate effect. Most of website you can see with one button left side or right side for scrolling top of the page. so, if you want to create on your site then you have to add following jquery code: <strong class="example">Example</strong> <pre class="prettyprint lang-html lang-js"> <style type="text/css"> #toTopImg{ position: fixed; bottom: 20px; left: 20px; cursor: pointer; display: none; z-index.....

By Hardik Savani | March 26, 2016 | | 9178 Viewer | Category : Javascript

How to remove particular value from jquery array?

When i was working on my code PHP project, at that time i need to remove specific items value from my javascript array. i did google search and solve that but i would like to share in my site how to remove value from javascript array. so, let's see how to use: <strong class="example">Example:</strong> <pre class="prettyprint lang-js"> var languages = ['php', 'laravel', '.net', 'java', 'c#', 'javascript'] var deleteLanguage = 'laravel'; languages = jQuery.grep(languages, function(value) { return value != deleteLanguage; }); console.log(languages); </pre>

By Hardik Savani | March 23, 2016 | | 5806 Viewer | Category : Javascript

How to remove undefined value from jquery array?

If you have jquery or javascript array with lots of undefined value and you want to remove all undefined value from array. you can remove undefined items from your array without using each loop you have to just use filter, I would like give the example how to remove undefined element from javascript array. so, let's see bellow example. <strong class="example"></strong> <pre class="prettyprint lang-javascript lang-html"> <script type="text/javascript"> var obj = ['3','3','5',undefined,'hi']; obj = obj.filter(function(e){return e}); console.log(obj); </script> </pre>

By Hardik Savani | March 12, 2016 | | 10973 Viewer | Category : Javascript