Check Element Type of Event Target with jQuery

Ricky Barnes
Updated on 11-Dec-2019 06:02:58

2K+ Views

To check the element type pf an event target, using the is() method.ExampleYou can try to run the following code to check the element type:Live Demo $(document).ready(function(){    $( "ul" ).click(function( event ) {       var target = $( event.target );       if ( target.is( "li" ) ) {          alert("Element is 'li'")       }   }); }); Click below to find out which element India US UK

Force Column Alias to Specific Data Type in MySQL

AmitDiwan
Updated on 11-Dec-2019 06:01:36

288 Views

For this, you can use CASE statement. Let us first create a table −mysql> create table DemoTable1505    -> (    -> Value integer unsigned,    -> Status tinyint(1)    -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1505 values(20, 0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1505 values(45, 1); Query OK, 1 row affected (0.08 sec)Display all records from the table using select statement −mysql> select * from DemoTable1505;This will produce the following output −+-------+--------+ | Value | Status | +-------+--------+ |   ... Read More

Swap a Specific Column Value in MySQL

AmitDiwan
Updated on 11-Dec-2019 06:00:12

293 Views

Let us first create a table table −mysql> create table DemoTable1504    -> (    -> Id int,    -> FirstName varchar(20)    -> ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1504 values(101, 'Chris'); Query OK, 1 row affected (0.63 sec) mysql> insert into DemoTable1504 values(102, 'Bob'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1504 values(103, 'David'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1504 values(104, 'Mike'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement ... Read More

Passing NULL to MySQL for Auto Increment

AmitDiwan
Updated on 11-Dec-2019 05:58:03

891 Views

Yes, we can pass NULL as in the below syntax −insert into yourTableName values(NULL, yourValue1, yourValue2, ...N);Let us first create a table −mysql> create table DemoTable1503    -> (    -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName varchar(20),    -> ClientAge int    -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command. Since we have set NOT NULL above, it won’t affect auto_increment −mysql> insert into DemoTable1503 values(NULL, 'Chris', 25); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1503 values(NULL, 'David', 28); Query OK, 1 row ... Read More

Get Largest Window Height and Width of Console in C#

AmitDiwan
Updated on 11-Dec-2019 05:57:36

263 Views

To get the largest window height of the Console, the code is as follows −Example Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Largest Window Height of the Console = "+Console.LargestWindowHeight);    } }OutputThis will produce the following output −Largest Window Height of the Console = 58ExampleTo get the largest window width of the Console, the code is as follows − Live Demousing System; public class Demo{    public static void Main(string[] args){       Console.WriteLine("Largest Window Width of the Console = "+Console.LargestWindowWidth);    } }OutputThis will produce the following output −Largest Window Width of the Console = 190

MySQL Query for Sorting on a Column's Partial Value Like Number

AmitDiwan
Updated on 11-Dec-2019 05:56:26

167 Views

For this, you can use SUBSTRING_INDEX() along with ORDER BY. Let us first create a table −mysql> create table DemoTable1502    -> (    -> StudentId varchar(40)    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1502 values('John_120'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1502 values('John_201'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1502 values('Mike_178'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1502 values('Bob_198'); Query OK, 1 row affected (0.36 sec)Display all records from the table using select ... Read More

Get Fourth Element of the Tuple in C#

AmitDiwan
Updated on 11-Dec-2019 05:54:53

110 Views

To get the fourth element of the Tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());       Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5);       Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5);       Console.WriteLine("Tuple1 Item 1st ... Read More

Select Multiple Rows Effectively in MySQL

AmitDiwan
Updated on 11-Dec-2019 05:53:17

3K+ Views

You need to use index to select multiple rows effectively. Let us first create a table −mysql> create table DemoTable1501    -> (    -> Id int NOT NULL PRIMARY KEY,    -> URL text    -> ); Query OK, 0 rows affected (0.62 sec)Here is the query to create index −mysql> create index id_index on DemoTable1501(Id); Query OK, 0 rows affected (0.23 sec) Records: 0  Duplicates: 0  Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable1501 values(101, 'www.facebook.com'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1501 values(110, 'www.google.com'); Query OK, 1 ... Read More

Get the Number of Key-Value Pairs in OrderedDictionary in C#

AmitDiwan
Updated on 11-Dec-2019 05:52:21

118 Views

To get the number of key/values pairs contained in OrderedDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("A", "Home Appliances");       dict.Add("B", "Electronics");       dict.Add("C", "Smart Wearables");       dict.Add("D", "Pet Supplies");       dict.Add("E", "Clothing");       dict.Add("F", "Footwear");       Console.WriteLine("OrderedDictionary elements...");       foreach(DictionaryEntry d in dict){          Console.WriteLine(d.Key + " " + d.Value);       }     ... Read More

Return Fields Appearing a Certain Number of Times Using MySQL DISTINCT

AmitDiwan
Updated on 11-Dec-2019 05:49:49

88 Views

To return fields appearing a certain number of times, the syntax is as follows −select distinct yourColumnName, count(yourColumnName) from yourTableName where yourColumnName LIKE 'J%' group by yourColumnName having count(*) > 1 order by yourColumnName;Let us first create a table −mysql> create table DemoTable1500    -> (    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −Mysql> insert into DemoTable1500 values(‘Adam’); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1500 values('John'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1500 values('Mike'); Query OK, 1 ... Read More

Advertisements