How does iframe ready Method Work in jQuery

Kristi Castro
Updated on 20-Jun-2020 07:24:24

3K+ Views

Here’s an example wherein the iframe size is larger than the page. We will scroll to the top of the page whenever the iframe loads using jQuery −ExampleLive Demo               $(document).ready(function(){       $("button").click(function(){         $('iframe').ready(function(){           $(window).scrollTop(0);         });       });    });           Loop through each image

Loop Through All Iframe Elements of a Page Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:22:57

1K+ Views

To loop through all the iframes element of a page, use the jQuery each() method. You can try to run the following code to learn how to loop through all iframes. We have created three iframes below −ExampleLive Demo $(document).ready(function(){   $("button").click(function(){     $("iframe").each(function(){       alert($(this).text())       });   }); });   Qries Q/A   Tutorialspoint Free Learning   Send Files   Loop through iFrames

Enable and Disable Submit Button Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:15:21

1K+ Views

To enable and disable submit button, use the jQuery prop() method. You can try to run the following code to enable and disable submit button using jQuery −ExampleLive Demo               $(document).ready(function() {       $('#register').click(function() {         $(this).prop('disabled',true);         $("#content").show();         setTimeout(function(){           $('#register').prop('disabled', false);         },3000);      });    });               The above button disables for 3 seconds, on clicking.                  

Submit Form with Multiple Submit Buttons using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:14:15

3K+ Views

Yes, you can submit form with multiple submit buttons. Attack a custom click handler to all the buttons and the check which button is clicked.ExampleLive Demo               $(document).ready(function(){       $("#myform button").click(function (ev) {       ev.preventDefault()       if ($(this).attr("value") == "button1") {                     alert("First Button is pressed - Form will submit")         $("#myform").submit();       }       if ($(this).attr("value") == "button2") {         alert("Second button is pressed - Form did not submit")       }     }); });     First Button   Second Button

Create DIV Dynamically Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:13:16

2K+ Views

To create a div dynamically, use the html() method. You can try to run the following code to learn how to create a div dynamically on button click −ExampleLive Demo               $(document).ready(function(){       $("button").click(function(){         $("body").html("This is a new div.");       });     });   Create a new div This is demo text.

Get All Unique Rows in MySQL Result Set

Vikyath Ram
Updated on 20-Jun-2020 07:09:52

267 Views

With the help of DISTINCT keyword in SELECT statement, we can get the unique rows in MySQL result set.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 4    | Aarav     | | 5    | Ram       | | 5    | Ram       | | 5    | Ram       | +------+-----------+ 7 rows in set (0.00 sec)As we can see that table ‘names’ is having three duplicate rows, with the help of following query we can get the result set having only unique rows.mysql> Select DISTINCT * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 4    | Aarav     | | 5    | Ram       | +------+-----------+ 5 rows in set (0.00 sec)

Difference Between SERIAL and AUTO_INCREMENT in MySQL

Srinivas Gorla
Updated on 20-Jun-2020 07:09:26

4K+ Views

In MySQL, both SERIAL and AUTO_INCREMENT are used to define a sequence as a default value for a field. But they are technically different from each other.The AUTO_INCREMENT attribute is supported by all numeric data types except for BIT and DECIMAL. There can only be one AUTO_INCREMENT field per table and the sequence generated by an AUTO_INCREMENT field in one table cannot be used in any other table. This attribute requires that a UNIQUE index exists on the field to ensure the sequence has no duplicates. The sequence would start by default from 1 and increment by 1 for every insert.Examplemysql> ... Read More

Store Fixed-Length and Variable-Length Strings in MySQL Table

Jennifer Nicholas
Updated on 20-Jun-2020 07:08:50

602 Views

As we know that CHAR is used to store fixed length string and VARCHAR is used to store variable length strings. Hence we can store a fixed length as well as variable length string in the same table by declaring a column as CHAR and other as VARCHAR.Examplemysql> Create Table Employees(FirstName CHAR(10), LastName VARCHAR(10)); Query OK, 0 rows affected (0.64 sec) mysql> Desc Employees; +-----------+-------------+------+-----+---------+-------+ | Field     | Type        | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | FirstName | char(10)    | YES  |     | NULL    |   ... Read More

Importance of Column Order in MySQL UPDATE Statement

Ankith Reddy
Updated on 20-Jun-2020 07:08:26

317 Views

The order of columns in the SET clause of UPDATE statement is important because MySQL provides us the updated value on columns names used in an expression. Yes, it will make big difference in the result set returned by MySQL. Following is an example to make it clear −ExampleIn this example, we are having a table ‘tender’. First, we will write UPDATE statement by using ‘tender_id’ as the first and ‘rate’ as the second column in SET clause and then we will write UPDATE statement by using ‘rate’ as the first and ‘tender_id’ as the second column on table ‘tender’.mysql> ... Read More

What MySQL Returns for Sub-query in UPDATE Statement

karthikeya Boyini
Updated on 20-Jun-2020 07:07:57

292 Views

In this case, MySQL will return an error message because we know that if sub-query is used to assign new values in the SET clause of UPDATE statement then it must return exactly one row for each row in the update table that matches the WHERE clause.Examplemysql> insert into info(id, remarks) values(5, 'average'); Query OK, 1 row affected (0.06 sec) mysql> select * from info; +------+-----------+ | id   | remarks   | +------+-----------+ | 1    | Good      | | 2    | Good      | | 3    | Excellent | | 4   ... Read More

Advertisements