Found 8895 Articles for Front End Technology

What is the difference between height and line-height?

Alex Onsman
Updated on 08-May-2020 11:06:32

2K+ Views

Height is the vertical measurement of the container, for example, height of a div.Line-height is a CSS property to specify the line height i.e. the distance from the top of the first line of text to the top of the second. It is the space between the lines of two paragraphs.ExampleYou can try to run the following code to learn the difference between height and line height:Live Demo                    .height {             height: 20px;          }          .lheight ... Read More

What is the difference between append() and appendTo() in jQuery?

Alex Onsman
Updated on 17-Dec-2019 08:58:07

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

How to get the width of a div element using jQuery?

Alex Onsman
Updated on 17-Dec-2019 08:26:30

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

How to set width and height of an element using jQuery?

Alex Onsman
Updated on 17-Dec-2019 10:02:29

4K+ 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

How jQuery selects elements using CSS?

Alex Onsman
Updated on 17-Dec-2019 10:00:52

407 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

How to use jQuery.slice() method with no arguments?

Alex Onsman
Updated on 17-Dec-2019 09:28:11

184 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.

How to apply multiple CSS properties using jQuery?

Alex Onsman
Updated on 01-Jul-2024 15:58:25

15K+ Views

Apply multiple CSS properties using jQuery CSS( {key1:val1, key2:val2....}) method. We can apply as many properties as we like in a single call. Syntax In the below mentioned way we can use the CSS. Here you can pass key as property and val as its value of that property. selector.css( {key1:val1, key2:val2....keyN:valN}) Define Multiple CSS Attributes in jQuery As we mentioned earlier that we will be using jQuery css() method to apply multpile CSS properties on any element. First we will use '$(selector)' to select the element where we wants to apply ... Read More

How to define multiple CSS attributes in jQuery?

Alex Onsman
Updated on 17-Dec-2019 09:26:57

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

How to apply CSS properties using jQuery?

Alex Onsman
Updated on 18-Dec-2019 07:02:57

702 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                            

How does CSS Selectors work in jQuery?

Amit D
Updated on 17-Dec-2019 09:21:51

117 Views

The jQuery library supports nearly all of the selectors included in Cascading Style Sheet (CSS) specifications 1 through 3, as outlined on the World Wide Web Consortium's site.Using jQuery library developers can enhance their websites without worrying about browsers and their versions as long as the browsers have JavaScript enabled.Most of the JQuery CSS Methods do not modify the content of the jQuery object and they are used to apply CSS properties on DOM elements.To apply any CSS property using jQuery method css( PropertyName, PropertyValue ).Here is the syntax for the method −selector.css( PropertyName, PropertyValue );Here you can pass PropertyName as ... Read More

Advertisements