I am currently trying to figure out a way to work within a selected <div> in order to be able to send a text formatted email.
So there is a button says “email”. When a user clicks on it, it grabs a closest div as below.
var selectedDiv = $(callingElement).closest(".myClassName");
And from there I would like to grab various dom elements to create a clean text format. So how do I work within selectedDiv using jQuery?
For example,
- Getting
<h1>value. - Getting
<li>value with certain class names - Getting “title” attribute value.
The
selectedDivjQuery object wraps thedivelement. Use thefindmethod to search for descendant elements, andattrto get the attributes on thedivelement itself.Call the
text()method to get the text from theh1, or theli.