I’m looking to run a script on a page that puts each piece of text that is italicized into an array.
As I understand jQuery .find() you can’t get items by attributes, am I right?
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.
You should get familiar with the
filter()method which is a great jQuery feature. You can define a filter function you can use to reduce the elements in your jQuery collection to the ones that fit your needs.You also need to use
.map()which is another super-handy method that can help you create lists from your jQuery collections defined by a function you write. Using.get()you can create a plain Javascript array from this jQuery list object.This is a basic version that will collect you the text content of elements that have
font-style: italicapplied to them:jsFiddle Demo