Alex Onsman has Published 144 Articles

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

Alex Onsman

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(){   ... Read More

How jQuery selects elements using CSS?

Alex Onsman

Alex Onsman

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

548 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 ... Read More

How to define multiple CSS attributes in jQuery?

Alex Onsman

Alex Onsman

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

2K+ 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 ... Read More

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

Alex Onsman

Alex Onsman

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

3K+ 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 ... Read More

What is the difference between width and innerWidth in jQuery?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 08:43:39

344 Views

Width in jQueryThe width is the horizontal measurement of the container, for example, width of a div. It excludes the padding, border, or margin.ExampleYou can try to run the following code to learn how to get the width of an element in jQuery:Live Demo $(document).ready(function(){   ... Read More

What is the difference between height and outerHeight in jQuery?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 08:37:32

2K+ Views

height in jQueryThe height() is the vertical measurement of the container, for example, height of a div. It excludes the padding border and margin.To get the height of an element in jQuery, use the height() method in jQuery.ExampleYou can try to run the following code to get the height:Live Demo ... Read More

How can I get the selected value of a drop-down list with jQuery?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 08:18:58

8K+ Views

With jQuery, it’s easy to get selected text from a drop-down list. This is done using the select id. To change the selected value of a drop-down list, use the val() method.ExampleYou can try to run the following code to learn how to change the selected value of a drop-down ... Read More

How to replace innerHTML of a div using jQuery?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 08:14:28

3K+ Views

To replace innerHTML of a div in jQuery, use the html() or text() method.ExampleYou can try to run the following code to learn how to replace innerHTML of a div:Live Demo $(document).ready(function(){     $("#button1").click(function(){          $('#demo').html('Demo text');    }); }); This is Amit! Replace

How to animate scrollLeft using jQuery?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 07:43:36

2K+ Views

To animate scrollLeft using jQuery, use the animate() method with scrollLeft.ExampleYou can try to run the following code to learn how to animate scrollLeft using jQuery:Live Demo $(document).ready(function(){     $('#scrollme').click(function() {     $('html, body').animate({         scrollLeft: $('#demo').css('left')     }, 500, ... Read More

How to position horizontal scroll bar at center of DIV?

Alex Onsman

Alex Onsman

Updated on 17-Dec-2019 07:41:36

4K+ Views

To position horizontal scroll bar at center of div, use the scrollleft. You can try to run the following code to position horizontal scroll bar in div.ExampleThe scroll bar is positioned at center of div:Live Demo               jQuery Scroll         ... Read More

Advertisements