jQuery Articles

Page 41 of 42

How to trim a string using $.trim() in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 15-Jun-2020 3K+ Views

To trim a string in jQuery, use the trim() method. It removes the spaces from starting and end of the string. The sample string I am using has spaces − var myStr = " Hello World "; Use the trim() method, jQuery.trim(myStr); The following is an example to trim a string in jQuery − Example $(document).ready(function(){   $("#button1").click(function(){     var myStr = "   Hello World      ";     myStr = jQuery.trim(myStr);     alert(myStr);   }); }); Trim

Read More

SAP UI5 framework and comparison with JQuesry and Backbone, Angular, etc.

karthikeya Boyini
karthikeya Boyini
Updated on 15-Jun-2020 286 Views

The SAPUI5 framework is the original version of the SAP toolkit which was released initially. This version of the toolkit is a proprietary version. Later SAP released an Open source version of it named OpenUI5. Functionally it is almost equivalent in terms of basic operations negating few features but overall sufficient enough as a UI framework.This UI5 framework (applies to both SAPUI5 and OpenUI5) is capable of dispensing all major tasks expected from a full-fledged UI framework. It supports following features:Model View Controller architectureRouting engineModules with the help of module loadersFull data binding either in XML, JSON or using web ...

Read More

Why would a jQuery variable start with a dollar sign?

Johar Ali
Johar Ali
Updated on 13-Jun-2020 414 Views

When you will begin working about jQuery, you will get to know about the usage of the $ sign. A $ sign is used to define jQuery.jQuery variables begin with $ to distinguish them from a standard JavaScript object. Also, it is a convention. jQuery selectors start with the dollar sign and parentheses() − $.Let's take an Example −// jQuery object var $phone = $("#myphone"); // dom object var phone_el = $("#myphone").get(1);

Read More

How can I alter the color of an HTML5 canvas element using jQuery?

Daniol Thomas
Daniol Thomas
Updated on 04-Mar-2020 337 Views

To alter the color of an HTML5 canvas, use −document.getElementById("ID").style.background = red;You can also try the following −var ctx = canvas.getContext('2d'); ctx.fillStyle = "#FF0000"; ctx.fill();

Read More

Where should jQuery code go in header or footer?

Ali
Ali
Updated on 20-Feb-2020 2K+ Views

It’s always a good practice to add jQuery code in footer i.e. just before the closing tag. If you have not done that, then use the defer attribute.Use defer attribute so the web browser knows to download your scripts after the HTML downloaded −The defer attribute is used to specify that the script execution occurs when the page loads. It is useful only for external scripts and is a boolean attribute.ExampleThe following code shows how to use the defer attribute −                 The external file added will load later, since we're using defer    

Read More

How do I put a jQuery code in an external .js file?

Ali
Ali
Updated on 20-Feb-2020 7K+ Views

Create an external JavaScript file and add the jQuery code in it.ExampleLet’s say the name of the external file is demo.js. To add it in the HTML page, include it like the following −                               Hello     Above we added jQuery using Google CDN and the external file was included after that.Add jQuery code in demo.js, since you wanted to place jQuery code −$(document).ready(function(){    alert(“amit”) });

Read More

How to include multiple js files using jQuery $.getScript() method?

David Meador
David Meador
Updated on 17-Feb-2020 768 Views

To use multiple js files, use the same getScript(), which is used to add a single js file. We’re having result.js file with the following code snippet −function CheckJS(){ alert("This is JavaScript - File1"); }We’re having result2.js file with the following code snippet −function CheckJS(){ alert("This is JavaScript – File2"); }ExampleHere's the code snippet to add multiple js files. Here, we will call the function in the above 2 js files − ...

Read More

What is the difference between jQuery.load() and jQuery.ajax() methods in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 17-Feb-2020 636 Views

jQuery ajax() methodThe jQuery.ajax( options ) method loads a remote page using an HTTP request. $.ajax() returns the XMLHttpRequest that it creates. In most cases you won't need that object to manipulate directly, but it is available if you need to abort the request manually.Here is the description of all the parameters used by this method −options − A set of key/value pairs that configure the Ajax request. All options are optional.Assuming we have the following HTML content in result.html file −THIS IS RESULT...ExampleThe following is an example showing the usage of this method. Here, we make use of success handler to ...

Read More

What is the difference between jQuery.post() and jQuery.get() methods in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 17-Feb-2020 350 Views

jQuery post() methodThe jQuery.post( url, [data], [callback], [type] ) method loads a page from the server using a POST HTTP request.Assuming we have following PHP content in result.php file, ExampleThe following is the code snippet showing the usage of this method − $(document).ready(function() { ...

Read More

What is the difference between Ajax and jQuery-Ajax methods in jQuery?

David Meador
David Meador
Updated on 12-Dec-2019 1K+ Views

Firstly, let’s go through what is Ajax and why it is used.AJAXAJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more interactive web applications with the help of XML, HTML, CSS, and Java Script.It has the following points, which shows its importance.AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more interactive web applications with the help of XML, HTML, CSS, and Java Script.Ajax uses XHTML for content, CSS for presentation, along with Document Object Model and JavaScript for dynamic content display.With AJAX, when ...

Read More
Showing 401–410 of 413 articles
Advertisements