How to Create Get Content and Attributes in jQuery

How to Create Get Content and Attributes in jQuery

In this article, you will learn How to Create Get Content and Attributes in jQuery. Get Content text() html() val() Example:- <html> <head> <title>Get Content</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#btn1").click(function(){ alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); }); }); </script> </head> <body> <p id="test">In this paragraph having some<b>bolded</b> text.</p> <button id="btn1">Show Text</button> […]
Read Full Article
How to Create AJAX Loading Method using JQuery

How to Create AJAX Loading Method using JQuery

In this article, you will learn How to Create AJAX Loading Method using JQuery. Example:- <html> <head> <title>AJAX Load Method in JQuery</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").load("test.txt", function(responseTxt, statusTxt, xhr){ if(statusTxt == "success") alert("External content loaded successfully!"); if(statusTxt == "error") alert("Error: " + xhr.status + ": " + xhr.statusText); }); }); }); </script> </head> <body> […]
Read Full Article
How to Create AJAX get() and post() Method in jQuery

How to Create AJAX get() and post() Method in jQuery

In this article, you will learn How to Create AJAX get() and post() Method. jQuery AJAX gets and post method is an important role in the HTTP server request. jQuery Get() Method <html> <head> <title>jQuery get() Method</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.get("get.php", function(data, status){ alert("Data: " + data + "\nStatus: " + status); }); }); […]
Read Full Article