How jquery modifies min-height Styles
Today Xiaobian to share with you how to modify the min-height style of jquery related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's learn about it together.
Modification method: 1. Use css() to set new style, syntax "$(element).css("min-height"," new value ")";2. Use attr() to add new style by setting style attribute, syntax "$(element).attr("style","min-height: new value ")".
This tutorial operates on Windows 7, jquery version 1.10.2, Dell G3 computers.
The min-height attribute is used to set the minimum height of the element. This property does not include padding, borders, or margins!
So how do you modify min-height styles using jquery?
In jquery, support a variety of ways to modify the min-height style, the following to introduce you.
Method 1: Use the CSS() method
The css() method returns or sets one or more style properties of the matching element.
Use the css() method to add a new value directly to the min-height attribute and set a new style.
Examples:
$(document).ready(function() { $("button").click(function() { $("p").css("min-height","100px"); }); }); p{ min-height:50px; border: 1px solid green; }
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
Modify min-height style
Method 2: Use attr() method
The attr() method sets or returns the attribute value of the selected element.
You can use this method to set the style attribute and add a new inline style to overwrite the old style.
Examples:
$(document).ready(function() { $("button").click(function() { $("p").attr("style","min-height:100px"); }); }); p{ min-height:50px; border: 1px solid green; }
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
Modify min-height style
The above is "jquery how to modify min-height style" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.