I’m trying to select the H2 that contains the most characters, or is the widest in width, whichever one is simpler, or if you know how to do it could you put both? I’m not sure of the syntax.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get the pixel-widest, you could just loop though kind of abusing the
.width()function, for example:You can test it out here. Inside this function
wis the current width, so we’re just seeing if it’s wider than our current widest, and if so setting the current width to the new widest andwidestto the current<h2>that was found to be wider than the previous widest.You can do something similar for character count using
.text():You can test that version here.