jQuery before() Method

AmitDiwan
Updated on 11-Nov-2019 12:37:45

218 Views

The before() method in jQuery is used to insert specified content before the selected elements.ExampleLet us now see an example to implement the before() method in jQuery −    $(document).ready(function(){       $("#btndemo").click(function(){          $("img").before("Text inserted before!");       });    }); Insert specified content OutputThis will produce the following output −Click on “Insert specified content” −

jQuery after() Method

AmitDiwan
Updated on 11-Nov-2019 12:34:08

269 Views

The after() method in jQuery is used to insert specified content after the selected elements.ExampleLet us now see an example to implement the jQuery after() method −    $(document).ready(function(){       $("#btndemo").click(function(){          $("img").after("Text inserted after!");       });    }); Insert specified content OutputThis will produce the following output −Click on the above button to display the text −

Add Elements Using jQuery with Examples

AmitDiwan
Updated on 11-Nov-2019 12:32:33

133 Views

To add elements in jQuery, let us see two methods: jQuery after() methodThe after() method in jQuery is used to insert specified content after the selected elements.ExampleLet us now see an example to implement the jQuery after() method −    $(document).ready(function(){       $("#btndemo").click(function(){          $("img").after("Text inserted after!");       });    }); Insert specified content OutputThis will produce the following output −Click on the above button to display the text −jQuery before() methodThe before() method in jQuery is used to insert specified content before the ... Read More

jQuery Hash ID Selector

AmitDiwan
Updated on 11-Nov-2019 12:25:34

195 Views

The #id selector in jQuery is used to select the element with the particular id.SyntaxThe syntax is as follows −$("#id")ExampleLet us now see an example to implement the jQuery #id selector −    .one {       color: white;       background-color: blue;    }    $(document).ready(function(){       $("#demo").addClass("one");    }); Car Details Car: Chevrolet Equinox 4-link rear suspension Automatic Emergency Braking Fuel Tank Capacity: Approx 14.9 gal OutputThis will produce the following output −

jQuery Selector

AmitDiwan
Updated on 11-Nov-2019 11:47:22

524 Views

The [attribute!=value] selector in jQuery is used to select each element that isn’t having the specified attribute and value.SyntaxThe syntax is as follows −$("[attribute!='value']")ExampleLet us now see an example to implement the jQuery [attribute!=value] selector −    .one {       color: white;       background-color: orange;       font-size: 16px;       border: 2px blue dashed;    }    $(document).ready(function(){       $("p[class!='demo']").addClass("one");    }); Car Details Car is XUV500 2179 cc Independent Suspension Fuel Tank Capacity: 70 litres OutputThis will produce the following output −

jQuery Class Selector

AmitDiwan
Updated on 11-Nov-2019 11:42:49

165 Views

The .class selector in jQuery is used to select all elements with the specific class.SyntaxThe syntax is as follows −$(".class")Above, the parameter class specify the class of the elements.ExampleLet us now see an example to implement the jQuery .class selector −    .one {       background-color: blue;       color: white;       font-size: 18px;       border: 2px blue dashed;    }    $(document).ready(function(){       $(".demo").addClass("one");    }); Heading One Heading Two Demo text 1... Demo text 2... Demo text 3... Demo text 4... OutputThis will produce the following output −

jQuery Visible Selector

AmitDiwan
Updated on 11-Nov-2019 11:37:23

173 Views

The :visible selector in jQuery is used to select elements that are currently visible.SyntaxThe syntax is as follows −$(":visible")ExampleLet us now see an example to implement the jQuery :visible selector −    $(document).ready(function(){       $("p:visible").css("color", "red");    }); Heading One Heading Two Demo text 1... Demo text 2... Demo text 3... Demo text 4... OutputThis will produce the following output −

jQuery Text Selector

AmitDiwan
Updated on 11-Nov-2019 11:33:57

282 Views

The :text selector in jQuery is used to select input elements with type text.SyntaxThe syntax is as follows −$(":text")ExampleLet us now see an example to implement the jQuery :text selector −    .one {       background-color: green;       color: white;       font-size: 15px;       border: 2px blue dashed;    }    $(document).ready(function(){       $(":text").addClass("one");    }); Fill the Form Username: Set Password: Reserved: Unreserved Products: Accessories Clothing Footwear Electronics Books Submit OutputThis will produce the following output −

Add Duplicate VARCHAR Values Without Error in MySQL

AmitDiwan
Updated on 11-Nov-2019 11:08:27

102 Views

For this, let us see an example and first create a −mysql> create table DemoTable1409    -> (    -> FirstName varchar(20),    -> UNIQUE KEY UN_FirstName(FirstName)    -> ); Query OK, 0 rows affected (0.79 sec)Following is the query to add duplicate varchar −mysql> alter table DemoTable1409 drop index  UN_FirstName; Query OK, 0 rows affected (0.40 sec) Records: 0  Duplicates: 0  Warnings: 0Insert some records in the table using insert −mysql> insert into DemoTable1409 values('Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1409 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1409 values('David'); ... Read More

Include Quotes in Comma-Separated Column with MySQL

AmitDiwan
Updated on 11-Nov-2019 11:04:22

896 Views

Let us first create a −mysql> create table DemoTable1407    -> (    -> Name text    -> ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert −mysql> insert into DemoTable1407 values('John, Bob'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1407 values('Carol, David, Adam'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1407 values('Mike, Sam, Chris'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select −mysql> select * from DemoTable1407;This will produce the following output −+------------------+ | Name             ... Read More

Advertisements