Suppose I have the following line of Code to create an anchor link:
$('<a>').css("width", 100)
The <a>
has width of 100. However, I did not give 100 a unit. Once the element is created and added to DOM, will it be given a width of 100px?
CodePudding user response:
According to the documentation:
When a number is passed as the value, jQuery will convert it to a string and add px to the end of that string. If the property requires units other than px, convert the value to a string and add the appropriate units before calling the method.
The answer to your question is yes, it will be given a width of 100px.