- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 766 Articles for JQuery
450 Views
To get the width of an element using jQuery, use the width() method.ExampleYou can try to run the following code to get the width of an element using jQuery:Live Demo $(document).ready(function(){ $("button").click(function(){ alert("Width of element: " + $("div").width()); }); }); Get Width
2K+ Views
To get the height of a div element, use the height() method in jQuery.ExampleYou can try to run the following code to get the height of a div element using jQuery:Live Demo $(document).ready(function(){ $("button").click(function(){ alert("Height of div element: " + $("div").height()); }); }); Get Height of div
2K+ Views
The append (content) method appends content to the inside of every matched element, whereas the appendTo (selector) method appends all of the matched elements to another, specified, set of elements.jQuery append() functionThe append (content) method appends content to the inside of every matched element.Here is the description of all the parameters used by this method −content − Content to insert after each target. This could be HTML or Text contentExampleYou can try to run the following code to learn how to work with append() function in jQuery:Live Demo jQuery append() method ... Read More
2K+ Views
To get the width of a div element, use the width() method in jQuery.ExampleYou can try to run the following code to get the width of a div element using jQuery:Live Demo $(document).ready(function(){ $("button").click(function(){ alert("Width of div element: " + $("div").width()); }); }); Get Width of div
3K+ Views
To set the width and height of an element using jQuery, use the width() and height() in jQuery.Width of an elementExampleYou can try to run the following code to learn how to set the width of an element in jQuery:Live Demo $(document).ready(function(){ $("#button1").click(function(){ $("div").width(300); }); $("#button2").click(function(){ $("div").width(400); }); }); Width of div: 300 Width of div: 400 Height of an elementExampleYou can try to run the following code to learn how to set the ... Read More
380 Views
jQuery uses CSS selector to select elements using CSS. Let us see an example to return a style property on the first matched element. The css( name ) method returns a style property on the first matched element.Here is the description of all parameter used by this method −name − The name of the property to access.ExampleYou can try to run the following code to learn how jQuery selects elements with CSS:Live Demo jQuery Example $(document).ready(function() { ... Read More
161 Views
The jQuery.slice() method is used to select subset of elements. It uses an index to set the selection. You can use it without arguments. Without argument, it will select all the elements.The slice() is equal to slice(0) i.e. without arguments.ExampleYou can try to run the following code to use jQuery slice() method without arguments:Live Demo $(document).ready(function(){ $("p").slice(0).css("background-color", "gray"); }); Heading 1 This is demo text 1. This is demo text 2. This is demo text 3.
14K+ Views
Apply multiple CSS properties using a single JQuery method CSS( {key1:val1, key2:val2....). You can apply as many properties as you like in a single call.Here is the syntax for the method −selector.css( {key1:val1, key2:val2....keyN:valN})Here you can pass key as property and val as its value as described above.ExampleYou can try to run the following code to learn how to apply multiple CSS properties using jQuery:Live Demo jQuery CSS $(document).ready(function() { $("li").eq(2).css({"color":"red", "background-color":"green"}); }); ... Read More
1K+ Views
To define multiple CSS attributes in jQuery, use the css selector or the addClass() method. Let’s see how to do it using css selector.Pair up strings representing property names with the corresponding values.ExampleYou can try to run the following code to learn how to define multiple CSS attributes in jQuery:Live Demo $(document).ready(function(){ $("#demo").css({ "background-color": "#F1F1F1", "font-style" : "italic" }); }); Countries
658 Views
To apply CSS properties using jQuery, use the css() method. It’s easy to apply any CSS property using jQuery method css( PropertyName, PropertyValue ).Here is the syntax for the method −selector.css( PropertyName, PropertyValue );ExampleHere you can pass PropertyName as a JavaScript string and based on its value, PropertyValue could be string or integer.Live Demo jQuery css() method $(document).ready(function() { $("li").eq(4).css("color", "green"); }); list item 1 list item 2 list item 3 list item 4 list item 5 list item 6