Remove All Child Nodes from a Parent Node using jQuery

David Meador
Updated on 15-Jun-2020 09:17:39

427 Views

Use the jQuery empty() method to remove all child nodes from a parent node.ExampleYou can try to run the following code to remove all child nodes from a parent node using jQuery:Live Demo $(document).ready(function(){       $("#button1").click(function(){          $("ul").empty();       }); });             li (child)       li (child)       li (child)       li (child)           Remove   Click Remove to remove all child nodes.

Append an Element After Another Element using jQuery

David Meador
Updated on 15-Jun-2020 09:16:45

3K+ Views

To append an element after an element using jQuery, use the insertAfter() method.ExampleYou can try to run the following code to learn how to append an element after an element using jQuery:Live Demo           The jQuery Example                              $(document).ready(function() {             $("div").click(function () {                $("#source").insertAfter(this);             });          });                              .div {             margin:10px;             padding:12px;             border:2px solid #666;             width:60px;          }                             Click on any square below to see the result:                                            

Remove Elements from a PriorityQueue using JavaScript

karthikeya Boyini
Updated on 15-Jun-2020 09:15:37

341 Views

Dequeuing elements from a PriorityQueue means removing the element of the highest priority. We are storing the elements with the highest priority at the end of the array, we can simply pop it to dequeue it.Hence, we can implement the dequeue function as follows − Exampledequeue() {    // Check if empty    if (this.isEmpty()) {       console.log("Queue Underflow!");       return;    }    return this.container.pop(); }You can check if this function is working fine usinglet q = new PriorityQueue(4); q.enqueue("Hello", 3); q.enqueue("World", 2); q.enqueue("Foo", 8); console.log(q.dequeue()); q.display();OutputThis will give the output −{ data: 'Foo', priority: 8 ... Read More

Manipulate CSS Pseudo-Elements Before and After Using jQuery

David Meador
Updated on 15-Jun-2020 09:15:13

3K+ Views

To manipulate CSS pseudo elements using the hover() function. You can try to run the following code to learn how to manipulate CSS pseudo-elements −ExampleLive Demo $(document).ready(function(){     $('span').hover(function(){     $(this).addClass('change').attr('data-content','bar'); }); }); span.change:after {     content: attr(data-content) ' This is demo text.'; } Place cursor below... foo

Get Style Property on Matched Element using jQuery

David Meador
Updated on 15-Jun-2020 09:14:33

419 Views

To get a style property on the matched element, use the css() method. You can try to run the following code to get a style property on the matched element using jQuery:Live Demo $(document).ready(function(){   $("#button1").click(function(){     alert($('div').css('left'));   }); }); This is demo text. Get

Java Labelled For Loop

Vikyath Ram
Updated on 15-Jun-2020 09:14:32

2K+ Views

Following program is using labeled for loops.ExampleLive Demopublic class Tester {    public static void main(String args[]) {             first:          for (int i = 0; i < 3; i++) {             for (int j = 0; j< 3; j++){                if(i == 1){                   continue first;                }                      System.out.print(" [i = " + i + ", ... Read More

Peeking Elements from a PriorityQueue using JavaScript

Samual Sam
Updated on 15-Jun-2020 09:14:15

145 Views

Peeking a PriorityQueue means getting the value with the highest priority without removing it. So we can implement the peek function as follows &minusl Examplepeek() {    if (isEmpty()) {       console.log("Queue Underflow!");       return;    }    return this.container[this.container.length - 1]; }You can check if this function is working fine using − Examplelet q = new PriorityQueue(4); q.enqueue("Hello", 3); q.enqueue("World", 2); q.enqueue("Foo", 8); console.log(q.peek()); q.display();OutputThis will give the output −{ data: 'Foo', priority: 8 } [ { data: 'World', priority: 2 },    { data: 'Hello', priority: 3 },    { data: 'Foo', priority: 8 } ]As ... Read More

Determine if a Variable is Undefined or Null

Swarali Sree
Updated on 15-Jun-2020 09:13:24

870 Views

On getting the result of the following, you can find whether a variable is null or undefined. If the result is “false”, it means the variable is null and undefined.Here, the variable results in “True” −                    var age = 10;          if(age) {             document.write("True");          } else {             document.write("False");          }          

Difference Between ajaxSend and ajaxStart Functions in jQuery

David Meador
Updated on 15-Jun-2020 09:13:18

467 Views

ajaxSend() methodThe ajaxSend(callback) method attaches a function to be executed whenever an AJAX request is sent.Here is the description of all the parameters used by this method:callback − The function to execute. The XMLHttpRequest and settings used for that request are passed as arguments to the callback.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:Live Demo           The jQuery Example                              $(document).ready(function() {           ... Read More

Clear Elements of the PriorityQueue using JavaScript

karthikeya Boyini
Updated on 15-Jun-2020 09:12:27

147 Views

We can clear the contents just by reassigning the container element to an empty array. For example, clear() {    this.container = []; }ExampleYou can check if this function is working fine using − let q = new PriorityQueue(4); q.enqueue("Hello", 3); q.enqueue("World", 2); q.enqueue("Foo", 8); q.display(); q.clear(); q.display();OutputThis will give the output −[ { data: 'World', priority: 2 },   { data: 'Hello', priority: 3 },   { data: 'Foo', priority: 8 } ] [ ]

Advertisements