Javascript examples for CSS Style Property:maxWidth
Return the maximum width of a <div> element:
<!DOCTYPE html> <html> <body> <div style="background:red;max-width:60px;" id="myDiv">This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</div><br> <button type="button" onclick="myFunction()">Return max width of div</button> <script> function myFunction() {/*from w w w .java2 s . c o m*/ console.log(document.getElementById("myDiv").style.maxWidth); } </script> </body> </html>